127MB image using multi-stage build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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