Skip to content

Instantly share code, notes, and snippets.

@oneteamai
Last active July 21, 2020 21:55
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 oneteamai/55a37087a349ca47f40b68478dd1a277 to your computer and use it in GitHub Desktop.
Save oneteamai/55a37087a349ca47f40b68478dd1a277 to your computer and use it in GitHub Desktop.
127MB image using multi-stage build
# module install
FROM node:13.10.1-alpine as module-install-stage
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json
RUN apk add yarn
RUN yarn install --production
# build
FROM node:13.10.1-alpine as build-stage
COPY --from=module-install-stage /app/node_modules/ /app/node_modules
WORKDIR /app
COPY . .
RUN yarn build
# serve
FROM node:13.10.1-alpine
COPY --from=build-stage /app/build/ /app/build
RUN npm install -g serve
# start app
CMD serve -s /app/build -l 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment