File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # syntax=docker.io/docker/dockerfile:1
2+
3+ FROM node:20-alpine AS base
4+
5+ # Dependencies stage
6+ FROM base AS dependencies
7+ WORKDIR /app
8+
9+ # Install curl and jq for healthchecks and JSON manipulation
10+ RUN apk add --no-cache curl libc6-compat jq
11+
12+ # Copy package files
13+ COPY package.json package-lock.json* ./
14+
15+ # Install dependencies
16+ RUN npm install
17+
18+ # Copy the rest of the app
19+ COPY . .
20+
21+ # Builder stage - creates production build
22+ FROM dependencies AS builder
23+ WORKDIR /app
24+
25+ # Build the Next.js app with all env vars available
26+ RUN npm run build
27+
28+ # Production image - run Next.js in production mode
29+ FROM base AS production
30+ WORKDIR /app
31+
32+ # Install curl for healthchecks
33+ RUN apk add --no-cache curl libc6-compat
34+
35+ # Copy necessary files from builder
36+ COPY --from=builder /app/package.json ./
37+ COPY --from=builder /app/node_modules ./node_modules
38+ COPY --from=builder /app/.next ./.next
39+ COPY --from=builder /app/next.config.mjs ./next.config.mjs
40+
41+ EXPOSE 3000
42+
43+ ENV PORT=3000
44+ ENV HOSTNAME="0.0.0.0"
45+ ENV NODE_ENV=production
46+
47+ # Start Next.js in production mode
48+ CMD ["npm" , "start" ]
You can’t perform that action at this time.
0 commit comments