Add a script to run node in a docker container.
Showing
2 changed files
with
33 additions
and
0 deletions
bin/run
0 → 100755
1 | #!/bin/sh | ||
2 | |||
3 | set -e | ||
4 | |||
5 | TOP_DIR="$(cd "$(dirname "$0")/.."; pwd -P)" | ||
6 | |||
7 | ti_arg="" | ||
8 | if [ -t 0 ]; then | ||
9 | ti_arg="-ti" | ||
10 | fi | ||
11 | docker run --rm $ti_arg \ | ||
12 | -e UID_REMAP=$(id -u) -e GID_REMAP=$(id -g) \ | ||
13 | -v "$TOP_DIR/container-entrypoint.sh:/container-entrypoint.sh" --entrypoint /container-entrypoint.sh \ | ||
14 | -w /srv/app \ | ||
15 | -v "$TOP_DIR:/srv/app" \ | ||
16 | $DOCKER_ARGS \ | ||
17 | node "$@" | ||
18 |
container-entrypoint.sh
0 → 100755
1 | #!/bin/bash | ||
2 | |||
3 | set -e | ||
4 | if [[ 0 -eq $(id -u) ]]; then | ||
5 | [[ $UID_REMAP ]] && usermod -u $UID_REMAP node | ||
6 | [[ $GID_REMAP ]] && groupmod -g $GID_REMAP node | ||
7 | fi | ||
8 | if [[ $# -eq 0 ]]; then | ||
9 | set -- bash | ||
10 | fi | ||
11 | |||
12 | cmd="$1" | ||
13 | shift | ||
14 | start-stop-daemon -c node -d $PWD -u node --start --exec "$(which "$cmd")" -- "$@" | ||
15 |
-
Please register or sign in to post a comment