Skip to content

Instantly share code, notes, and snippets.

@fedorg
Last active November 3, 2022 21:43
Show Gist options
  • Save fedorg/3c7b8a4b58d50764c84b760c06f9de56 to your computer and use it in GitHub Desktop.
Save fedorg/3c7b8a4b58d50764c84b760c06f9de56 to your computer and use it in GitHub Desktop.
Docker aliases to node, npm, npx to run in .bashrc
node_env='development'
node_image='node'
function run_node() {
args=( "$@" )
shift
binary="${args[0]}"
docker run --net=host --user $(id -u):$(id -g) -it --rm -e HOME=$HOME -e NODE_ENV=$node_env -v $HOME:$HOME -v $(pwd):/usr/app/ -w /usr/app --entrypoint $binary $node_image $@
}
function npm() { run_node npm $@; }
function node() { run_node node $@; }
function npx() { run_node npx $@; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment