-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (32 loc) · 928 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
### Building stage
FROM node:20.1.0-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY src ./src
COPY next.config.js .
COPY tsconfig.json .
COPY tailwind.config.ts .
COPY postcss.config.mjs .
COPY prisma ./prisma/
COPY public ./public
RUN npx prisma generate
RUN npm run build && \
npm prune --production && \
npm cache clean --force
### Production stage
FROM node:20.1.0-alpine
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN mkdir .next
RUN chown nextjs:nodejs .next
RUN npm install prisma -g && rm -rf /root/.npm /root/.cache
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
ENV NODE_ENV=production \
PORT=3000 \
HOSTNAME="0.0.0.0"
USER nextjs
CMD ["npm", "run", "start:prod"]