49 lines
1.3 KiB
Docker
49 lines
1.3 KiB
Docker
|
|
# Multi-stage production Dockerfile for Frontend (Next.js 15)
|
||
|
|
# Supports Linux VPS, Cloud Run, AWS ECS, and Windows Docker Desktop
|
||
|
|
|
||
|
|
FROM node:22-alpine AS builder
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy root package files
|
||
|
|
COPY package*.json ./
|
||
|
|
COPY packages/shared/package*.json ./packages/shared/
|
||
|
|
COPY apps/frontend/package*.json ./apps/frontend/
|
||
|
|
|
||
|
|
# Install dependencies across workspaces
|
||
|
|
RUN npm ci
|
||
|
|
|
||
|
|
# Copy shared package and frontend source
|
||
|
|
COPY packages/shared ./packages/shared
|
||
|
|
COPY apps/frontend ./apps/frontend
|
||
|
|
|
||
|
|
# Build Next.js production bundle
|
||
|
|
WORKDIR /app/apps/frontend
|
||
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||
|
|
ENV NODE_ENV=production
|
||
|
|
RUN npm run build
|
||
|
|
|
||
|
|
# ==============================================================
|
||
|
|
# Production Runner Stage
|
||
|
|
# ==============================================================
|
||
|
|
FROM node:22-alpine AS runner
|
||
|
|
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
ENV NODE_ENV=production
|
||
|
|
ENV PORT=3000
|
||
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||
|
|
|
||
|
|
# Copy public assets and built Next.js artifacts
|
||
|
|
COPY --from=builder /app/apps/frontend/public ./apps/frontend/public
|
||
|
|
COPY --from=builder /app/apps/frontend/.next ./apps/frontend/.next
|
||
|
|
COPY --from=builder /app/apps/frontend/package.json ./apps/frontend/package.json
|
||
|
|
COPY --from=builder /app/node_modules ./node_modules
|
||
|
|
COPY --from=builder /app/apps/frontend/node_modules ./apps/frontend/node_modules
|
||
|
|
|
||
|
|
WORKDIR /app/apps/frontend
|
||
|
|
|
||
|
|
EXPOSE 3000
|
||
|
|
|
||
|
|
CMD ["npm", "start"]
|