From 344cf646ea5f71c7b19756bb9326c11740e7fd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=ED=97=8C?= Date: Thu, 18 Jun 2026 15:50:04 +0900 Subject: [PATCH] =?UTF-8?q?feat(docker):=20negosium=20=ED=94=84=EB=A1=A0?= =?UTF-8?q?=ED=8A=B8=20=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=ED=99=94(:3300?= =?UTF-8?q?)=20+=20backend=20CORS=203300=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - frontend/Dockerfile: 프로덕션 빌드(npm run build) 후 vite preview 정적 서빙, 포트 3300. API URL(VITE_API_BASE_URL=http://localhost:9300)은 빌드 타임에 .env.prod.local 로 주입. - docker-compose.yml: negosium-front 서비스 추가(빌드 이미지, live volume 없음) + 헤더에 프론트 URL. - backend CORS(config.local.toml.example)에 http://localhost:3300 / 127.0.0.1:3300 추가. Co-Authored-By: Claude Opus 4.8 (1M context) --- backend/config/config.local.toml.example | 4 ++-- docker-compose.yml | 15 ++++++++++++--- frontend/.dockerignore | 4 ++++ frontend/Dockerfile | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile diff --git a/backend/config/config.local.toml.example b/backend/config/config.local.toml.example index 8f95efc..06082bd 100644 --- a/backend/config/config.local.toml.example +++ b/backend/config/config.local.toml.example @@ -7,8 +7,8 @@ port = 9300 process_count = 1 is_ssl = false is_test = true -# CORS 허용 오리진(프론트). 비우면 [] (CORS 미적용). 예: 로컬 Vite = http://localhost:5173 -cors_origins = ["http://localhost:5173", "http://127.0.0.1:5173"] +# CORS 허용 오리진(프론트). 비우면 [] (CORS 미적용). 5173=vite dev, 3300=docker 프로덕션 빌드 서빙. +cors_origins = ["http://localhost:5173", "http://127.0.0.1:5173", "http://localhost:3300", "http://127.0.0.1:3300"] [LogConfig] print_console = true diff --git a/docker-compose.yml b/docker-compose.yml index 557841f..c821657 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,9 +4,10 @@ # 컨테이너에서 호스트의 DB 에 접속할 때는 host.docker.internal 을 쓴다. # # docker compose up -d -# negosium 서버: http://localhost:9300/docs -# negodata 서버: http://localhost:9400/docs -# agent 서버: http://localhost:9500/docs +# negosium 서버: http://localhost:9300/docs +# negosium 프론트: http://localhost:3300 +# negodata 서버: http://localhost:9400/docs +# agent 서버: http://localhost:9500/docs # # DB 준비(최초 1회): postgres-init 의 SQL 을 대상 DB 에 적용한다. # psql -h -p -U -f postgres-init/01-schema.sql (단일 negosium_db + 도메인별 schema) @@ -62,3 +63,11 @@ services: extra_hosts: - "host.docker.internal:host-gateway" restart: unless-stopped + + # negosium 공급사 프론트 (프로덕션 빌드 정적 서빙, :3300). 브라우저가 backend(:9300)를 직접 호출. + negosium-front: + build: ./frontend + container_name: negosium-front + ports: + - "3300:3300" + restart: unless-stopped diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..62b26e1 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,4 @@ +node_modules +dist +.git +*.md diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..faa6511 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,19 @@ +FROM node:20-alpine + +WORKDIR /app + +# 의존성 (레이어 캐시) +COPY package.json package-lock.json ./ +RUN npm ci + +COPY . . + +# 프로덕션 빌드. API URL 은 빌드 타임에 번들로 인라인되므로 여기서 주입한다(로컬 도커: backend=localhost:9300). +# npm run build 는 --mode prod → .env.prod 를 읽으므로, 최우선 파일 .env.prod.local 로 덮어쓴다. +ARG VITE_API_BASE_URL=http://localhost:9300 +RUN echo "VITE_API_BASE_URL=$VITE_API_BASE_URL" > .env.prod.local && npm run build + +EXPOSE 3300 + +# 빌드 산출물(dist)을 정적 서빙. SPA 라우팅(history fallback)은 vite preview 가 처리. +CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "3300"]