Skip to content

Commit

Permalink
Only run npm install /app when starting non-production apps
Browse files Browse the repository at this point in the history
The npm install functionality ran on each launch.  The installed
packages are already fetched during the build phase, hence there
should be no reason to fetch the npm packages again unless we are
running in development mode.

The earlier implementations also did an npm install of the image's
packages.  These should be bundled with the image and should not be
updated accidentally.  Hence we choose to only run the npm install on
build of the template image, not on the build of the docker image
which uses this template.
  • Loading branch information
madnificent committed Aug 27, 2018
1 parent 2a87466 commit ea9478c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ ONBUILD RUN if [ -f /app/on-build.sh ]; \
&& chmod +x /app/on-build.sh \
&& /bin/bash /app/on-build.sh ;\
fi
ONBUILD RUN cd /usr/src/app && npm install && if [ -f "/app/package.json" ]; then npm install /app; fi
ONBUILD RUN if [ -f "/app/package.json" ]; then npm install /app; fi
10 changes: 3 additions & 7 deletions boot.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#! /bin/sh
## Install new dependencies
if [ -f "/app/package.json" ];
then
npm install /app
fi
npm install

if [ "$NODE_ENV" == "production" ];
then
./node_modules/supervisor/lib/cli-wrapper.js \
-i . \
-k --ignore-symlinks \
-x sh start.sh
else
## Install new dependencies
if [ -f "/app/package.json" ]; then npm install /app; fi
## Boot the app in development mode
./node_modules/supervisor/lib/cli-wrapper.js \
-w /usr/src/app,/app \
-i /usr/src/app/node_modules,/usr/src/app/helpers,/app/node_modules \
Expand Down

0 comments on commit ea9478c

Please sign in to comment.