mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-11 20:11:42 +00:00
Dockerfile: improve caching by installing devDependencies before copying the code
This should help avoid having to run the npm install for devDependencies (which are actually most of the modules) every time there's a change in the code. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
11
Dockerfile
11
Dockerfile
@ -142,16 +142,17 @@ RUN mkdir -p rootfs-overlay && \
|
|||||||
COPY package.json /usr/src/app/
|
COPY package.json /usr/src/app/
|
||||||
|
|
||||||
# Install only the production modules that have C extensions
|
# Install only the production modules that have C extensions
|
||||||
|
# Save the modules and then install devDependencies for build
|
||||||
RUN JOBS=MAX npm install --production --no-optional --unsafe-perm \
|
RUN JOBS=MAX npm install --production --no-optional --unsafe-perm \
|
||||||
&& npm dedupe
|
&& npm dedupe \
|
||||||
|
&& cp -R node_modules node_modules_prod \
|
||||||
|
&& npm install --no-optional --unsafe-perm
|
||||||
|
|
||||||
COPY webpack.config.js fix-jsonstream.js /usr/src/app/
|
COPY webpack.config.js fix-jsonstream.js /usr/src/app/
|
||||||
COPY src /usr/src/app/src
|
COPY src /usr/src/app/src
|
||||||
|
|
||||||
# Install devDependencies, build the coffeescript and then prune the deps
|
# Build the coffeescript and then restore the production modules
|
||||||
RUN cp -R node_modules node_modules_prod \
|
RUN npm run lint \
|
||||||
&& npm install --no-optional --unsafe-perm \
|
|
||||||
&& npm run lint \
|
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& mv node_modules_prod node_modules
|
&& mv node_modules_prod node_modules
|
||||||
|
Reference in New Issue
Block a user