FROM node:22-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . # NEXT_PUBLIC_* variables are inlined into JS bundles at build time. # Pass the real API URL as a build argument — it cannot be changed at runtime. ARG NEXT_PUBLIC_API_URL=/api/v1 ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL RUN npm run build # ───────────────────────────────────────────────────────────────────────────── FROM node:22-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME=0.0.0.0 # next.config.ts has output: 'standalone' — copy only what the standalone server needs RUN mkdir -p ./public COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static EXPOSE 3000 CMD ["node", "server.js"]