Skip to content

Commit 17e31c7

Browse files
committed
Reduce filesize for Docker image
From about 1 gigabyte to 400 megabytes
1 parent 7dc3967 commit 17e31c7

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Dockerfile

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1-
FROM node:14
1+
# Stage 1 - Build
2+
FROM node:14 AS builder
23

34
WORKDIR /app
4-
COPY . /app/
55

6-
RUN yarn
6+
COPY package.json yarn.lock /app/
7+
RUN yarn --frosen-lockfile
8+
9+
COPY . /app/
710
RUN NEXT_TELEMETRY_DISABLED=1 yarn next build
811

12+
13+
# Stage 2 - Running the app
14+
FROM node:14-alpine
15+
16+
WORKDIR /app
17+
ENV NODE_ENV production
18+
19+
# You only need to copy next.config.js if you are NOT using the default configuration
20+
COPY --from=builder /app/next.config.js ./
21+
#COPY --from=builder /app/public ./public
22+
COPY --from=builder /app/.next ./.next
23+
COPY --from=builder /app/node_modules ./node_modules
24+
COPY --from=builder /app/package.json ./package.json
25+
926
EXPOSE 80
1027

11-
ENTRYPOINT ["yarn", "start", "-p", "80"]
28+
ENTRYPOINT ["yarn", "next", "start", "-p", "80"]

0 commit comments

Comments
 (0)