From 1519c8003646c76b3309cef29126f17f2c798341 Mon Sep 17 00:00:00 2001 From: Brice Date: Thu, 22 Nov 2018 11:05:44 +1100 Subject: [PATCH] Enable calling node commands (npm, bower, etc) from the host with 'docker-compose exec' (#1481) --- workspace/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 9899308..5070e40 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -487,6 +487,20 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # Add PATH for node ENV PATH $PATH:/home/laradock/.node-bin +# Make it so the node modules can be executed with 'docker-compose exec' +# We'll create symbolic links into '/usr/local/bin'. +RUN if [ ${INSTALL_NODE} = true ]; then \ + find $NVM_DIR -type f -name node -exec ln -s {} /usr/local/bin/node \; && \ + NODE_MODS_DIR="$NVM_DIR/versions/node/$(node -v)/lib/node_modules" && \ + ln -s $NODE_MODS_DIR/bower/bin/bower /usr/local/bin/bower && \ + ln -s $NODE_MODS_DIR/gulp/bin/gulp.js /usr/local/bin/gulp && \ + ln -s $NODE_MODS_DIR/npm/bin/npm-cli.js /usr/local/bin/npm && \ + ln -s $NODE_MODS_DIR/npm/bin/npx-cli.js /usr/local/bin/npx && \ + ln -s $NODE_MODS_DIR/vue-cli/bin/vue /usr/local/bin/vue && \ + ln -s $NODE_MODS_DIR/vue-cli/bin/vue-init /usr/local/bin/vue-init && \ + ln -s $NODE_MODS_DIR/vue-cli/bin/vue-list /usr/local/bin/vue-list \ +;fi + RUN if [ ${NPM_REGISTRY} ]; then \ . ~/.bashrc && npm config set registry ${NPM_REGISTRY} \ ;fi