Instantly share code, notes, and snippets.

Embed
What would you like to do?
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