File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Next.js Production Dockerfile for Railway
2- # Build context is repository root, website is subdirectory
3- FROM node:20-alpine AS base
2+ FROM node:20-alpine
43
5- # Dependencies stage
6- FROM base AS deps
7- RUN apk add --no-cache libc6-compat
84WORKDIR /app
95
6+ # Install dependencies
107COPY website/package.json website/package-lock.json* ./
118RUN npm ci
129
13- # Builder stage
14- FROM base AS builder
15- WORKDIR /app
16- COPY --from=deps /app/node_modules ./node_modules
10+ # Copy website source
1711COPY website/ ./
1812
13+ # Build the app
1914ENV NEXT_TELEMETRY_DISABLED=1
2015RUN npm run build:railway
2116
22- # Runner stage
23- FROM base AS runner
24- WORKDIR /app
25-
17+ # Runtime
2618ENV NODE_ENV=production
27- ENV NEXT_TELEMETRY_DISABLED=1
28-
29- RUN addgroup --system --gid 1001 nodejs
30- RUN adduser --system --uid 1001 nextjs
31-
32- COPY --from=builder /app/public ./public
33- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
34- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
35-
36- USER nextjs
37-
38- EXPOSE 3000
3919ENV PORT=3000
40- ENV HOSTNAME= "0.0.0.0"
20+ EXPOSE 3000
4121
42- CMD ["node " , "server.js " ]
22+ CMD ["npm " , "start " ]
You can’t perform that action at this time.
0 commit comments