Skip to content

[feat] Dockerfile, docker-compose, Kubernetes 매니페스트 추가 (nginx 정적 호스팅)#114

Open
dasomel wants to merge 1 commit into
eGovFramework:mainfrom
dasomel-eGovFramework:feat/docker-and-k8s-5.0.x
Open

[feat] Dockerfile, docker-compose, Kubernetes 매니페스트 추가 (nginx 정적 호스팅)#114
dasomel wants to merge 1 commit into
eGovFramework:mainfrom
dasomel-eGovFramework:feat/docker-and-k8s-5.0.x

Conversation

@dasomel
Copy link
Copy Markdown

@dasomel dasomel commented May 20, 2026

변경 사유

컨테이너 이미지/k8s 매니페스트가 없어 vite build 후 수동 배포만 가능합니다. nginxinc/nginx-unprivileged:1.27-alpine 기반의 운영 가능한 최소 산출물을 추가합니다.

변경 내용

  • Dockerfile — multi-stage node:22-alpinenginxinc/nginx-unprivileged:1.27-alpine
    • 빌드 단계: npm ci + npm run build
    • 런타임: nginx 설정을 SPA용으로 교체
      • 포트 8080 (unprivileged 이미지 기본)
      • try_files로 React Router HTML5 history mode 지원
      • /assets/*는 1년 immutable 캐시
      • /index.html은 no-cache
  • .dockerignorenode_modules/, dist/, coverage/, IDE/.env 등 제외
  • docker-compose.yml — 단일 서비스, ${APP_VERSION:-5.0.0} 변수화
  • k8s/deployment.yaml — 2 replica RollingUpdate, runAsNonRoot(uid 101 nginx-unprivileged 기본), readOnlyRootFilesystem, drop ALL, 정적 서빙에 맞춘 리소스(50m–300m CPU / 32Mi–128Mi), liveness/readiness probe, /var/cache/nginx//var/run//tmp emptyDir로 read-only root 호환
  • k8s/service.yaml — ClusterIP 8080

영향 범위

  • 애플리케이션 코드 변경 없음
  • package.json 변경 없음
  • image: 태그는 예시 — 운영 환경 레지스트리로 교체 필요
  • API 엔드포인트가 동일 origin이 아닌 경우 nginx 설정에 reverse proxy 블록을 별도로 추가 권장

체크리스트

  • 단일 주제(프론트엔드 컨테이너화 + k8s 매니페스트)
  • 5.0.x 브랜치 대상
  • 기존 코드 미변경

The repo has no container image definition or k8s manifests — the only
deployment path is 'vite dev'/'vite build' + manually copying dist to a
web server. Add a production-shaped set that serves the Vite bundle
from nginx-unprivileged.

- Dockerfile: multi-stage Node 22 -> nginx-unprivileged 1.27 Alpine.
  Build stage uses 'npm ci' for reproducibility and 'npm run build'.
  Runtime stage replaces the default nginx config with one that:
    - listens on 8080 (matches the unprivileged image's user)
    - serves the SPA with try_files fallback for HTML5 router
    - caches /assets/* aggressively (Vite emits hashed filenames)
    - bypasses cache for /index.html
- .dockerignore: keep build context small (node_modules/, dist/,
  build/, coverage/, IDE/.env files).
- docker-compose.yml: single-service compose for demo runs, image tag
  parameterised via ${APP_VERSION:-5.0.0}.
- k8s/deployment.yaml: replicas=2 RollingUpdate, runAsNonRoot (uid 101
  matches nginx-unprivileged), readOnlyRootFilesystem, drop ALL,
  resources sized for static serving (50m-300m CPU, 32Mi-128Mi),
  separate liveness/readiness probes, ephemeral
  /var/cache/nginx, /var/run, /tmp emptyDirs so the read-only root
  filesystem profile works.
- k8s/service.yaml: ClusterIP exposing port 8080.
@dasomel dasomel changed the base branch from 5.0.x to main May 26, 2026 15:53
@dasomel dasomel changed the title [feat][5.0.x] Dockerfile, docker-compose, Kubernetes 매니페스트 추가 (nginx 정적 호스팅) [feat] Dockerfile, docker-compose, Kubernetes 매니페스트 추가 (nginx 정적 호스팅) May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant