Skip to content

Instantly share code, notes, and snippets.

@yindia
Created January 7, 2019 17:32
Show Gist options
  • Save yindia/a999a3de685e748f06860c8b46720dc5 to your computer and use it in GitHub Desktop.
Save yindia/a999a3de685e748f06860c8b46720dc5 to your computer and use it in GitHub Desktop.
# Stage 1 - the build process
FROM node:10.11.0-alpine AS base
MAINTAINER evalsocket@protonmail.com
WORKDIR /usr/src/app
# dev image contains everything needed for testing, development and building
FROM base AS development
COPY package.json yarn.lock ./
# first set aside prod dependencies so we can copy in to the prod image
RUN yarn install --pure-lockfile --production
RUN cp -R node_modules /tmp/node_modules
# install all dependencies and add source code
RUN yarn install --pure-lockfile
COPY . .
# builder runs unit tests and linter, then builds production code
FROM development as builder
RUN yarn build
# Stage 2 - the production environment
FROM base AS release
COPY --from=builder /tmp/node_modules ./node_modules
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/package.json ./
EXPOSE 8081
CMD ["yarn", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment