Skip to content

Instantly share code, notes, and snippets.

@wesleyegberto
Created May 19, 2020 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleyegberto/a0dc1da88168acf8e75f1abcb8e41c55 to your computer and use it in GitHub Desktop.
Save wesleyegberto/a0dc1da88168acf8e75f1abcb8e41c55 to your computer and use it in GitHub Desktop.
Example of Dockerfile to build Node app using multistage to lower its image size (without the large node_node modules).
# Stage 1 - the build process
FROM node:10-alpine as build-deps
WORKDIR /src
COPY package.json package-lock.json ./
RUN npm i --silent
COPY . ./
RUN npm run build
# Stage 2 - the production environment
FROM nginx:1.12-alpine
COPY --from=build-deps /src/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment