-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (28 loc) · 794 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (28 loc) · 794 Bytes
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
# Dockerfile
FROM node:20-alpine AS base
WORKDIR /app
COPY package.json package-lock.json ./
FROM base AS development
RUN npm ci
COPY . .
USER node
CMD ["npm", "run", "dev"]
FROM base AS builder
RUN npm ci
COPY . .
RUN DATABASE_URL="postgresql://build:build@localhost/build" npx prisma generate
ENV NODE_OPTIONS="--max-old-space-size=1536"
RUN npm run build
# Full node_modules for running migrations and seeds
FROM builder AS migrator
# Lean runtime — only the standalone Next.js server
FROM node:20-alpine AS production
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Run as non-root for defense in depth.
USER node
EXPOSE 3000
CMD ["node", "server.js"]