31 lines
1.4 KiB
Docker
31 lines
1.4 KiB
Docker
# Bach to Basics: frontend image
|
|
# Multi-stage build: pnpm build, static files served by nginx with /api proxy
|
|
|
|
# ── Stage 1: build ──────────────────────────────────────────────────────────
|
|
FROM node:20-alpine AS builder
|
|
|
|
# 잠금 파일과 공식 CI가 사용하는 pnpm 9로 고정해 새 주 버전으로 인한 빌드 실패를 막는다.
|
|
RUN corepack enable && corepack prepare pnpm@9 --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Workspace lockfile + manifests at the repo root drive deterministic installs.
|
|
# Build context is the repo root (see docker-compose.yml).
|
|
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
|
COPY shared ./shared
|
|
COPY frontend ./frontend
|
|
|
|
RUN pnpm install --frozen-lockfile --filter ./frontend...
|
|
RUN pnpm --filter frontend build
|
|
|
|
# ── Stage 2: serve ──────────────────────────────────────────────────────────
|
|
FROM nginx:1.27-alpine
|
|
|
|
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
|
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY frontend/docker-entrypoint.d/20-backend-api-key.sh /docker-entrypoint.d/20-backend-api-key.sh
|
|
RUN chmod 755 /docker-entrypoint.d/20-backend-api-key.sh
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|