2026-07-30 12:14:24 +07:00
|
|
|
# ---- Builder stage: Next.js static export ----
|
|
|
|
|
FROM node:22-slim AS builder
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
WORKDIR /build
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-07-27 21:54:31 +07:00
|
|
|
RUN corepack enable
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Build essentials
|
2026-07-27 21:54:31 +07:00
|
|
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
2026-07-30 12:14:24 +07:00
|
|
|
make g++ \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Manifest files first
|
|
|
|
|
COPY services/frontend/package.json ./
|
|
|
|
|
COPY services/frontend/tsconfig.json ./
|
|
|
|
|
COPY services/frontend/next.config.ts ./
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Install all deps, skip postinstall (no native addons needed for static export)
|
2026-07-27 21:54:31 +07:00
|
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
2026-07-30 12:14:24 +07:00
|
|
|
pnpm install --ignore-scripts --no-frozen-lockfile
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Source code
|
|
|
|
|
COPY services/frontend/ ./
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Build args
|
2026-07-27 21:54:31 +07:00
|
|
|
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}
|
|
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# Build static export
|
2026-07-27 21:54:31 +07:00
|
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
2026-07-30 12:14:24 +07:00
|
|
|
npx next build
|
2026-07-27 21:54:31 +07:00
|
|
|
|
2026-07-30 12:14:24 +07:00
|
|
|
# ---- Runtime stage: nginx ----
|
2026-06-02 08:36:34 +07:00
|
|
|
FROM nginx:alpine
|
|
|
|
|
|
2026-06-02 09:26:47 +07:00
|
|
|
COPY infra/docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
2026-07-30 12:14:24 +07:00
|
|
|
COPY --from=builder /build/out/ /usr/share/nginx/html/
|
2026-07-04 03:03:36 +07:00
|
|
|
|
2026-06-02 08:36:34 +07:00
|
|
|
EXPOSE 80
|
|
|
|
|
|
2026-07-27 21:54:31 +07:00
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
|
|
|
CMD wget -qO- http://localhost:80/ || exit 1
|
|
|
|
|
|
2026-06-02 08:36:34 +07:00
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|