JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
silence more warnings
[wfpl-cms.git] / build
1 #!/bin/bash
2
3 # ENV / defaults
4 image="${DOCKER_IMAGE-node:latest}"
5 port="${PORT-8080}"
6
7 if [ -z "$1" ]; then
8     echo "USAGE: $0 [development|production]" >&2
9     exit 1
10 fi
11
12 cd "$(dirname "$0")" || exit $?
13
14
15 run_in_docker() {
16     path="$(readlink -f "$(dirname "$0")")"
17     docker run -i -t -u "$(id -u):$(id -g)" -p "$port:8080" --rm -v "$path/:$path":rw -w "$path" "$image" "$@"
18 }
19
20 if [ ! -f .npm-initialized -o package.json -nt .npm-initialized ]; then
21     run_in_docker npm install || exit $?
22     mkdir -p css/dist
23     touch .npm-initialized
24 fi
25
26 run_in_docker npm run "$@"