JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
progress on webpacking css
[wfpl-cms.git] / build
diff --git a/build b/build
new file mode 100755 (executable)
index 0000000..e639fe2
--- /dev/null
+++ b/build
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# ENV / defaults
+image="${DOCKER_IMAGE-node:latest}"
+port="${PORT-8080}"
+
+if [ -z "$1" ]; then
+    echo "USAGE: $0 [development|production]" >&2
+    exit 1
+fi
+
+cd "$(dirname "$0")" || exit $?
+
+
+run_in_docker() {
+    path="$(readlink -f "$(dirname "$0")")"
+    docker run -i -t -u "$(id -u):$(id -g)" -p "$port:8080" --rm -v "$path/:$path":rw -w "$path" "$image" "$@"
+}
+
+if [ ! -f .npm-initialized -o package.json -nt .npm-initialized ]; then
+    run_in_docker npm install || exit $?
+    mkdir -p css/dist
+    touch .npm-initialized
+fi
+
+run_in_docker npm run "$@"