-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (57 loc) · 2.04 KB
/
Dockerfile
File metadata and controls
78 lines (57 loc) · 2.04 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Build stage
FROM node:24-alpine AS builder
# Install dependencies needed for building
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install pnpm
RUN npm install -g pnpm
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy Prisma schema and seed files
COPY prisma ./prisma
# Generate Prisma client FIRST
RUN npx prisma generate
# Copy rest of source code
COPY . .
# Build the application
RUN pnpm build
# Production stage
FROM node:24-alpine AS runner
# Install dependencies needed for runtime
RUN apk add --no-cache \
dumb-init \
curl
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Set working directory
WORKDIR /app
# Install Prisma CLI and tsx for TypeScript execution
RUN npm install -g prisma@6.13.0 @prisma/client@6.13.0 tsx
# Copy built application from builder stage
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/public ./public
# Copy Prisma files AND the generated client
COPY --from=builder --chown=nextjs:nodejs /app/prisma/schema.prisma ./prisma/schema.prisma
COPY --from=builder --chown=nextjs:nodejs /app/prisma/demodata.ts ./prisma/demodata.ts
COPY --from=builder --chown=nextjs:nodejs /app/prisma/seed.ts ./prisma/seed.ts
COPY --from=builder --chown=nextjs:nodejs /app/prisma/migrations ./prisma/migrations
COPY --from=builder --chown=nextjs:nodejs /app/lib/generated ./lib/generated
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
# Copy start script
COPY --chown=nextjs:nodejs start.sh ./start.sh
RUN chmod +x start.sh
# Switch to non-root user
USER nextjs
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/api/health || exit 1
# Start the application with our script
ENTRYPOINT ["dumb-init", "--"]
CMD ["./start.sh"]