From 1eb0f478233e25db555f5d450668c3581d88b149 Mon Sep 17 00:00:00 2001 From: Lacky1234union Date: Mon, 5 Oct 2026 13:40:24 +0300 Subject: [PATCH] =?UTF-8?q?chore(devops):=20patient=20web=20app=20in=20doc?= =?UTF-8?q?ker=20compose=20=E2=80=94=20the=20jury=20needs=20only=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Requirement: no extra software beyond the regulated set. The web app is built in a Node stage and served by nginx (:8080, /api → app, SSE unbuffered); the server override keeps it off (host nginx serves the bundle). Co-Authored-By: Claude Opus 5.5 --- Makefile | 2 +- README.md | 6 +++--- docker-compose.yml | 9 +++++++++ infra/deploy/docker-compose.server.yml | 4 ++++ web/.dockerignore | 3 +++ web/Dockerfile | 12 ++++++++++++ web/nginx.conf | 18 ++++++++++++++++++ 7 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 web/.dockerignore create mode 100644 web/Dockerfile create mode 100644 web/nginx.conf diff --git a/Makefile b/Makefile index 6e871cc..a379f33 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ install: up: @test -f .env || cp .env.example .env docker compose up -d --build - @echo "API: http://localhost:8000/docs Dashboard: http://localhost:8501" + @echo "Patient app: http://localhost:8080 API: http://localhost:8000/docs Doctor/demo console: http://localhost:8501" down: docker compose down diff --git a/README.md b/README.md index a1c5108..8ec9919 100644 --- a/README.md +++ b/README.md @@ -36,17 +36,17 @@ ## 3. Развёртывание и запуск -**Требования:** Docker с Compose v2. Для локальной разработки — Python 3.12 и [uv](https://docs.astral.sh/uv/); для сборки веб-приложения — Node 20 (или docker-образ `node:20-alpine`). +**Требования:** только Docker с Compose v2 — всё остальное собирается в контейнерах. Для разработки — Python 3.12 и [uv](https://docs.astral.sh/uv/), Node 20. ```bash cp .env.example .env # по умолчанию офлайн: LLM_PROVIDER=mock, агент выключен -make up # postgres + API (:8000) + кабинет врача и демо-консоль (:8501) +make up # postgres + API (:8000) + кабинет врача/демо-консоль (:8501) + приложение пациента (:8080) make seed # синтетический кабинет: врач, ветеран Андрей и 7 пациентов ``` - API и Swagger: http://localhost:8000/docs - Кабинет врача и демо-консоль: http://localhost:8501 -- Веб-приложение пациента: `cd web && npm ci && npm run dev`, затем http://localhost:5173 (`/api` проксируется на :8000) +- Веб-приложение пациента: http://localhost:8080 (собирается внутри Docker, Node на машине не нужен; для разработки — `cd web && npm run dev`, :5173) **Включить чат-агента** в `.env`: - `CHAT_AGENT=gigachat` + `GIGACHAT_CREDENTIALS=…` — целевой вариант для РФ; diff --git a/docker-compose.yml b/docker-compose.yml index 2d1d3d4..79bb6ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,5 +47,14 @@ services: ports: - "8501:8501" + web: + # Patient web app (React) — built inside Docker, no Node needed on the host. + build: ./web + depends_on: + app: + condition: service_healthy + ports: + - "8080:80" + volumes: pgdata: diff --git a/infra/deploy/docker-compose.server.yml b/infra/deploy/docker-compose.server.yml index 24a835f..440bcca 100644 --- a/infra/deploy/docker-compose.server.yml +++ b/infra/deploy/docker-compose.server.yml @@ -28,3 +28,7 @@ services: - "127.0.0.1:8511:8501" restart: unless-stopped mem_limit: 768m + + web: + # On the server the host nginx serves the web bundle itself (deploy.sh builds web/dist). + profiles: ["local-only"] diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 0000000..b431156 --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +.vite diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..def43b0 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,12 @@ +# Patient web app: build with Node in a throwaway stage, serve the static bundle with nginx (+ /api → app). +# The jury only needs Docker: `make up` builds and starts it (http://localhost:8080). +FROM node:20-alpine AS build +WORKDIR /w +COPY package.json package-lock.json ./ +RUN npm ci --no-audit --no-fund +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /w/dist /usr/share/nginx/html diff --git a/web/nginx.conf b/web/nginx.conf new file mode 100644 index 0000000..35d72de --- /dev/null +++ b/web/nginx.conf @@ -0,0 +1,18 @@ +# Same-origin API: the app calls /api/v1/... — proxied to the FastAPI container (SSE streaming unbuffered). +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /api/ { + proxy_pass http://app:8000; + proxy_set_header Host $host; + proxy_http_version 1.1; + proxy_buffering off; + proxy_read_timeout 120s; + } +} -- 2.54.0