2026-06-08 17:51:29 +07:00
|
|
|
# ---- Builder Stage ----
|
|
|
|
|
FROM node:22-alpine AS builder
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-06-01 23:31:20 +07:00
|
|
|
ARG VITE_BE_API_URL
|
|
|
|
|
ARG VITE_BE_WS_URL
|
|
|
|
|
|
2026-06-01 21:44:29 +07:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install pnpm
|
|
|
|
|
RUN npm install -g pnpm
|
|
|
|
|
|
2026-06-09 20:35:35 +07:00
|
|
|
# Copy dependency definition files first for caching
|
2026-06-01 21:44:29 +07:00
|
|
|
COPY pnpm-workspace.yaml .
|
|
|
|
|
COPY pnpm-lock.yaml .
|
|
|
|
|
COPY package.json .
|
|
|
|
|
|
2026-06-02 23:31:12 +07:00
|
|
|
# Copy patches (pnpm patchedDependencies)
|
|
|
|
|
COPY patches ./patches
|
|
|
|
|
|
2026-06-09 20:35:35 +07:00
|
|
|
# Copy workspace dependency
|
|
|
|
|
COPY packages/shared ./packages/shared
|
|
|
|
|
|
2026-06-01 22:47:47 +07:00
|
|
|
# Copy service
|
2026-06-01 21:44:29 +07:00
|
|
|
COPY services/frontend ./services/frontend
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
2026-06-09 20:35:35 +07:00
|
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
|
|
|
pnpm install --frozen-lockfile
|
|
|
|
|
|
|
|
|
|
# Build shared workspace dependency first (required for TypeScript declarations)
|
|
|
|
|
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
|
|
|
|
pnpm --filter './packages/shared' run build
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-06-01 23:31:20 +07:00
|
|
|
# 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
|
2026-06-01 21:44:29 +07:00
|
|
|
|
2026-06-08 17:51:29 +07:00
|
|
|
# ---- 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
|
|
|
|
|
|
2026-06-01 21:44:29 +07:00
|
|
|
EXPOSE 3000
|
|
|
|
|
|
2026-06-08 17:51:29 +07:00
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|