-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (46 loc) · 1.77 KB
/
Dockerfile
File metadata and controls
62 lines (46 loc) · 1.77 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Stage 1: Build the application
# We name this stage 'builder'
FROM node:22-alpine AS builder
# Set the working directory
WORKDIR /app
# Install pnpm globally
RUN npm install -g pnpm
# Copy package manifests and lockfile
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --strict-peer-dependencies=false
# Copy the rest of your application code
COPY . .
# Run Prisma Generate (this is safe and often needed for types)
RUN npx prisma generate
# Build the application. This succeeds because the database is available.
RUN pnpm run build
# Stage 2: Production Image
# Create a smaller, cleaner image for production
FROM node:22-alpine
WORKDIR /app
# ===================================================================
# THE FIX: Install pnpm in the final production image as well.
# ===================================================================
RUN npm install -g pnpm
# Install netcat for the entrypoint healthcheck
RUN apk add --no-cache netcat-openbsd
# Set environment variables for better console output
ENV FORCE_COLOR=1
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Copy only the necessary production artifacts from the 'builder' stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
COPY --from=builder /app/public ./public
COPY docker-entrypoint.sh .
# Ensure the entrypoint is executable
RUN chmod +x docker-entrypoint.sh
# This is the command that will run when the container starts
ENTRYPOINT ["./docker-entrypoint.sh"]
# The default command for the entrypoint script
CMD ["pnpm", "start"]