Skip to content

Instantly share code, notes, and snippets.

@itsmunim
Last active April 19, 2020 16:39
Show Gist options
  • Save itsmunim/6a9a289ced9fc85bfb4729e13c86136e to your computer and use it in GitHub Desktop.
Save itsmunim/6a9a289ced9fc85bfb4729e13c86136e to your computer and use it in GitHub Desktop.
Multi stage docker build for NodeJS Service
# installation step #
FROM node:lts-alpine3.9 AS builder
ENV BUILD_DIR /build
RUN mkdir -p $BUILD_DIR
WORKDIR $BUILD_DIR
COPY . $BUILD_DIR/
RUN npm install --no-audit
# if you have any build step, you should include that
# in this stage as well. e.g. npm run build
# package image step
FROM node:lts-alpine3.9 AS runtime
EXPOSE 8080
# -- #
ENV APP_HOME /app
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
COPY --from=builder /build ./
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment