Skip to content

Instantly share code, notes, and snippets.

@mloberg
Created April 21, 2017 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mloberg/10494e70c71f2f479e29b576b410189d to your computer and use it in GitHub Desktop.
Save mloberg/10494e70c71f2f479e29b576b410189d to your computer and use it in GitHub Desktop.
WIP: Run npm via Docker
npm () {
[ -n "$NODE_VERSION" ] || NODE_VERSION="latest"
tty=
tty -s && tty=--tty
docker run \
$tty \
--interactive \
--rm \
--user $(id -u):$(id -g) \
--volume /etc/passwd:/etc/passwd:ro \
--volume /etc/group:/etc/group:ro \
--volume $HOME/.npm:/.npm \
--volume $(pwd):/app \
--workdir /app \
--entrypoint npm \
"node:${NODE_VERSION}" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment