Files
GMW/infra/docker/Dockerfile.proxy
T

47 lines
1.2 KiB
Docker
Raw Normal View History

# ---- Builder stage: Next.js static export ----
FROM node:22-slim AS builder
WORKDIR /build
RUN corepack enable
# Build essentials
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
make g++ \
&& rm -rf /var/lib/apt/lists/*
# Manifest files first
COPY services/frontend/package.json ./
COPY services/frontend/tsconfig.json ./
COPY services/frontend/next.config.ts ./
# Install all deps, skip postinstall (no native addons needed for static export)
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --ignore-scripts --no-frozen-lockfile
# Source code
COPY services/frontend/ ./
# Build args
ARG VITE_BE_API_URL
ARG VITE_BE_WS_URL
ENV VITE_BE_API_URL=${VITE_BE_API_URL}
ENV VITE_BE_WS_URL=${VITE_BE_WS_URL}
# Build static export
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
npx next build
# ---- Runtime stage: nginx ----
FROM nginx:alpine
COPY infra/docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /build/out/ /usr/share/nginx/html/
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost:80/ || exit 1
CMD ["nginx", "-g", "daemon off;"]