Skip to content

Instantly share code, notes, and snippets.

@oneteamai
Last active Jul 21, 2020
Embed
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
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