-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (32 loc) · 960 Bytes
/
Dockerfile
File metadata and controls
47 lines (32 loc) · 960 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
35
36
37
38
39
40
41
42
43
44
45
46
47
# Builder Stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json* ./
COPY ./prisma ./prisma
# Install all dependencies (including devDependencies)
RUN npm install
# Generate Prisma client
RUN npx prisma generate
# Build the application
COPY . .
RUN npm run build
# Production Stage
FROM node:20-alpine AS production
WORKDIR /app
ENV NODE_ENV production
# Copy package files
COPY package.json package-lock.json* ./
# Copy node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
# Remove dev dependencies
RUN npm prune --production
# Copy Prisma files
COPY --from=builder /app/prisma ./prisma
# Copy built application
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/next.config.js* ./
EXPOSE 3000
# Run migrations and start
CMD ["sh", "-c", "npx prisma migrate deploy && npm start"]