Browse Source

Use Docker multistage build to reduce image size

The building will happen on the regular `node:8` image, but the final image will run `node:8-alpine` which will reduce the image size from 960 MB to 120 MB

https://docs.docker.com/develop/develop-images/multistage-build/
fix-133-memory-crash
Henri Kuittinen 5 years ago
committed by GitHub
parent
commit
5c65b542d1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Dockerfile

6
Dockerfile

@ -1,6 +1,10 @@
FROM node:8 FROM node:8 as builder
WORKDIR /workspace WORKDIR /workspace
COPY . . COPY . .
RUN npm install RUN npm install
FROM node:8-alpine
WORKDIR /workspace
COPY --from=builder /workspace .
CMD npm start CMD npm start
EXPOSE 3002 EXPOSE 3002

Loading…
Cancel
Save