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- # Use Node.js 20 as base image
2- FROM node:20-slim
1+ # Next.js Production Dockerfile for Railway
2+ # Build context is repository root, website is subdirectory
3+ FROM node:20-alpine AS base
34
5+ # Dependencies stage
6+ FROM base AS deps
7+ RUN apk add --no-cache libc6-compat
48WORKDIR /app
59
6- # Copy package files from website directory
710COPY website/package.json website/package-lock.json* ./
11+ RUN npm ci
812
9- # Install dependencies
10- RUN npm ci --legacy-peer-deps
11-
12- # Copy website files
13+ # Builder stage
14+ FROM base AS builder
15+ WORKDIR /app
16+ COPY --from=deps /app/node_modules ./node_modules
1317COPY website/ ./
1418
15- # Build the Next.js application (using Railway-specific build)
19+ ENV NEXT_TELEMETRY_DISABLED=1
1620RUN npm run build:railway
1721
18- # Expose port
19- EXPOSE 8080
22+ # Runner stage
23+ FROM base AS runner
24+ WORKDIR /app
2025
21- ENV PORT=8080
2226ENV 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
39+ ENV PORT=3000
40+ ENV HOSTNAME="0.0.0.0"
2341
24- # Start the application
25- CMD ["npm" , "run" , "start" ]
42+ CMD ["node" , "server.js" ]
You can’t perform that action at this time.
0 commit comments