Files
GMW/infra/docker/Dockerfile.frontend
T
MythEclipseandClaude Opus 4.8 <noreply@anthropic.com d036fbf568 opt(deploy): multi-stage frontend (node→nginx), non-root user, healthchecks, resource limits
Frontend:
- Multi-stage build: builder (node:22-alpine) → runner (nginx:alpine)
  replaces vite preview (400MB RAM) with nginx static serving (<20MB RAM)
- New nginx-frontend.conf with gzip + long-term asset cache + SPA fallback

Backend & Discord Gateway:
- Add non-root user (USER app) for container security
- chown app files to avoid permission issues
- Add HEALTHCHECK: backend via /api/health, gateway via kill -0 1

Docker Compose:
- Remove unnecessary backend→gateway depends_on
- Add deploy.resources.limits.memory for all services
- Add healthchecks for all services

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com
2026-06-08 17:51:29 +07:00

41 lines
903 B
Docker

# ---- Builder Stage ----
FROM node:22-alpine AS builder
ARG VITE_BE_API_URL
ARG VITE_BE_WS_URL
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy workspace files
COPY pnpm-workspace.yaml .
COPY pnpm-lock.yaml .
COPY package.json .
# Copy patches (pnpm patchedDependencies)
COPY patches ./patches
# Copy service
COPY services/frontend ./services/frontend
# Install dependencies
RUN pnpm install --frozen-lockfile
# Build frontend (env vars injected at build time)
RUN VITE_BE_API_URL=${VITE_BE_API_URL} VITE_BE_WS_URL=${VITE_BE_WS_URL} pnpm --filter './services/frontend' run build
# ---- Runner Stage ----
FROM nginx:alpine
# Copy Nginx config
COPY infra/docker/nginx/nginx-frontend.conf /etc/nginx/conf.d/default.conf
# Copy built static files from builder stage
COPY --from=builder /app/services/frontend/dist /usr/share/nginx/html
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]