Skip to content

Instantly share code, notes, and snippets.

Last active July 21, 2020 21:55
What would you like to do?
127MB image using multi-stage build
# module install
FROM node:13.10.1-alpine as module-install-stage
# set working directory
# 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
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