Skip to content

Commit c0a9337

Browse files
committed
Update on the production deployment
1 parent d6da84a commit c0a9337

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

docker/Dockerfile.prod

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1-
FROM node:14-alpine
1+
FROM node:18-alpine AS base
2+
3+
RUN npm i -g pnpm
4+
5+
FROM base AS dependencies
6+
7+
COPY package*.json pnpm-lock.yaml ./
8+
9+
RUN pnpm install
10+
11+
FROM base AS builder
212

313
WORKDIR /app
414

5-
COPY package*.json yarn.lock* ./
15+
COPY . .
16+
17+
COPY --from=dependencies /node_modules ./node_modules
18+
19+
RUN pnpm build
20+
21+
FROM builder AS prod
22+
23+
ENV NODE_ENV production
24+
25+
RUN addgroup --system --gid 1001 nodejs
26+
RUN adduser --system --uid 1001 nextjs
27+
28+
COPY --from=builder /app/public ./public
29+
30+
RUN mkdir .next
31+
RUN chown nextjs:nodejs .next
632

7-
RUN yarn
33+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
34+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
835

9-
COPY ./ ./
36+
USER nextjs
1037

11-
RUN yarn build
38+
EXPOSE 3000
1239

13-
CMD ["yarn", "start"]
40+
CMD ["pnpm", "start"]

docker/docker-compose.prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
build:
77
context: ../
88
dockerfile: docker/Dockerfile.prod
9+
target: prod
910
restart: on-failure
1011
ports:
1112
- 3000:3000

0 commit comments

Comments
 (0)