rsnext/examples/with-docker/Dockerfile.multistage
Nghiệp 111d2df90c
[Examples] Optimize with-docker (#17116)
* Fix missing yarn.lock
* Add --frozen-lockfile flag to speed up install deps
* Make sure node_modules do not contains devDependencies
* Add --targe stage docker build
2020-09-21 04:09:37 +00:00

28 lines
No EOL
598 B
Docker

# Stage 1: Building the code
FROM mhart/alpine-node AS builder
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn build
RUN yarn install --production --frozen-lockfile
# Stage 2: And then copy over node_modules, etc from that stage to the smaller base image
FROM mhart/alpine-node:base as production
WORKDIR /app
# COPY package.json next.config.js .env* ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node_modules/.bin/next", "start"]