구조: 내부 API 진입점을 admin/backend 로 옮긴다
admin/ 이 프론트만 있는 폴더였다. :9801 을 띄우는 코드는 solution/backend 안에 admin_main.py 로 얹혀 있었는데, 그러면 폴더만 봐서는 admin 에 백엔드가 있다는 걸 모른다. solution/backend/admin_main.py → admin/backend/main.py solution/backend/router/admin_router.py → admin/backend/app.py 도메인 코드는 여전히 복제하지 않는다 — `PYTHONPATH=/app/solution/backend` 한 줄이 두 폴더를 잇는다. admin/backend 에 있는 건 진입점 두 파일뿐이다. ## 이미지 빌드 컨텍스트를 레포 루트로 올렸다 진입점이 admin/ 에, 도메인 코드가 solution/ 에 있어서 한 이미지에 둘 다 들어와야 한다. 나누면 requirements 를 두 번 설치하게 된다. 컨텍스트가 넓어진 만큼 루트 .dockerignore 로 프론트·문서·테스트·시크릿을 잘라냈다(옛 solution/backend/.dockerignore 대체). 이미지 배치: /app/solution/backend ← 도메인 코드. api·worker 의 working_dir /app/admin/backend ← 내부 API 진입점. api-admin 의 working_dir 검증: api·api-admin 둘 다 healthy, 다섯 엔드포인트(9800·9801·3000·3002·80) 전부 200. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019uYhHQdssRubirPirrdJJC
This commit is contained in:
1 parent
c6b45fdda4
commit
cabcdeaacc
9 files changed
+84
-59
No files matched your search
+20
-15
@@ -1,35 +1,40 @@
|
||||
# o2o-web4ai 백엔드 이미지 — API 와 워커가 **같은 이미지**를 공유하고 command 로만 갈린다.
|
||||
# API : python web_main.py (요청 접수/조회, :9800)
|
||||
# 워커 : python worker_main.py (수집·비전분석·빌드 잡 처리, 포트 없음)
|
||||
# o2o-web4ai 백엔드 이미지 — 세 프로세스가 **같은 이미지**를 공유하고 command 로만 갈린다.
|
||||
# 사장님 API : python web_main.py (:9800)
|
||||
# 내부 API : python main.py (:9801, working_dir=/app/admin/backend)
|
||||
# 워커 : python worker_main.py (수집·비전분석·빌드 잡, 포트 없음)
|
||||
#
|
||||
# Phase 1 은 collector 가 MockAdapter 만 등록하므로 브라우저가 필요 없다 → 이 lean 이미지 하나면 된다.
|
||||
# 크롤링 법무 검토가 끝나 HeadlessAdapter 를 붙이면, 그때 Chrome+Xvfb 를 담은 별도 워커 이미지
|
||||
# (Dockerfile.worker)를 만들어 갈라낸다 — 선례: o2o-negosium/lps/Dockerfile.worker
|
||||
# ★ 빌드 컨텍스트가 **레포 루트**다(./solution/backend 가 아니다).
|
||||
# 내부 API 진입점이 admin/backend 에 있고 도메인 코드는 solution/backend 에 있어서,
|
||||
# 한 이미지에 둘 다 들어와야 한다. 나누면 requirements 를 두 번 설치하게 된다.
|
||||
#
|
||||
# 시크릿은 이미지에 굽지 않는다 — config 는 example(플레이스홀더)로 대체되고,
|
||||
# 실제 값은 compose 의 env(DB_USER/DB_PASSWORD, *_API_KEY 등)로 주입된다(server_configs override).
|
||||
# 실제 값은 compose 의 env 로 주입된다(server_configs override).
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 의존성 먼저 설치 (레이어 캐시 활용)
|
||||
COPY requirements.txt .
|
||||
COPY solution/backend/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
COPY solution/backend ./solution/backend
|
||||
COPY admin/backend ./admin/backend
|
||||
|
||||
# 시크릿 든 config.local.toml 은 .dockerignore 로 제외됨 → example(플레이스홀더)로 대체.
|
||||
# 실값은 env 주입: DB_HOST/DB_PORT/DB_USER/DB_PASSWORD/DB_NAME,
|
||||
# PERPLEXITY_API_KEY/KAKAO_REST_API_KEY/GEMINI_API_KEY/TOUR_API_KEY
|
||||
RUN cp config/config.local.toml.example config/config.local.toml
|
||||
RUN cp solution/backend/config/config.local.toml.example solution/backend/config/config.local.toml
|
||||
|
||||
# 항상 APP_ENV=local 로 실행 → config.local.toml(=example 사본) + env override.
|
||||
ENV APP_ENV=local
|
||||
# ★ 내부 API(admin/backend)가 common·router·services 를 그대로 import 하는 경로.
|
||||
# 도메인 코드를 복제하지 않는 대신 이 한 줄이 두 폴더를 잇는다.
|
||||
ENV PYTHONPATH=/app/solution/backend
|
||||
|
||||
# 기본은 사장님 API. 내부 API·워커는 compose 가 working_dir·command 를 갈아끼운다.
|
||||
WORKDIR /app/solution/backend
|
||||
|
||||
EXPOSE 9800
|
||||
|
||||
# API 컨테이너용. 워커는 command 를 갈아끼우고 이 헬스체크를 쓰지 않는다
|
||||
# (워커는 포트가 없다 — 하트비트 파일 기반 체크는 필요해질 때 추가한다).
|
||||
# 사장님 API 컨테이너용. 워커는 포트가 없어 이 체크를 끄고, 내부 API 는 :9801 로 다시 건다
|
||||
# (둘 다 compose 에서 override).
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:9800/healthz', timeout=4).status==200 else 1)"
|
||||
|
||||
|
||||
Reference in new issue
Block a user