From 284995d79c6670d2db6fe915dfa234d239bf82e7 Mon Sep 17 00:00:00 2001 From: wuyongtao Date: Tue, 21 Jul 2026 11:36:43 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20Docker=20?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE=E5=8F=8A=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- docker/README.md | 10 ++++++++++ docker/app/Dockerfile.backend | 2 ++ docker/app/docker-compose.yml | 2 +- docs/deployment-plan.md | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docker/README.md b/docker/README.md index 1fc5b98..3d458f9 100644 --- a/docker/README.md +++ b/docker/README.md @@ -58,6 +58,8 @@ $images | ForEach-Object { docker pull $_ } | Compute API | `19100` | `9100` | 算力服务器 API | | File Gateway | `19101` | 后续服务端口 | 当前预留,后续拆出文件网关服务时使用 | +注意:`8000` 是后端容器内部端口,不作为宿主机对外访问端口。宿主机或浏览器应访问 `http://:17861/modelTF/health`;前端 Nginx 容器在 Docker 网络内部访问 `http://backend-api:8000/modelTF/...`。 + 对应配置文件: - `docker/app/.env.example` @@ -79,6 +81,8 @@ $images | ForEach-Object { docker pull $_ } 应用服务器包含前端 Nginx、Backend API、PostgreSQL、Redis。 +当前 Compose 内置 PostgreSQL 使用 `backend/app/db/sql/001_platform_runtime.sql` 初始化运行库。`docs/postgres-schema.sql` 是完整目标架构设计,不应直接挂载为当前运行库初始化脚本,否则会与当前后端代码的运行表结构不兼容。 + 首次部署: ```bash @@ -100,6 +104,12 @@ cp .env.example .env docker compose up -d ``` +后端镜像构建过程中会执行依赖导入自检,确认 `fastapi`、`uvicorn`、`psycopg`、`sqlalchemy`、`redis` 等运行依赖已安装。构建后也可以手动检查: + +```bash +docker run --rm yg-ft-backend-api:latest python -c "import psycopg; print(psycopg.__version__)" +``` + 默认访问地址: ```text diff --git a/docker/app/Dockerfile.backend b/docker/app/Dockerfile.backend index 57b0364..4367cb0 100644 --- a/docker/app/Dockerfile.backend +++ b/docker/app/Dockerfile.backend @@ -11,6 +11,8 @@ RUN pip install --upgrade pip \ && pip install -r /tmp/requirements.txt \ && rm -f /tmp/requirements.txt +RUN python -c "import fastapi, uvicorn, psycopg, sqlalchemy, redis, jwt, passlib, httpx, alembic; print('backend dependency check ok')" + RUN mkdir -p /opt/yg-ft/logs/backend /data/yg-ft \ && chmod -R 0775 /opt/yg-ft /data/yg-ft diff --git a/docker/app/docker-compose.yml b/docker/app/docker-compose.yml index f380a4a..9edc5ee 100644 --- a/docker/app/docker-compose.yml +++ b/docker/app/docker-compose.yml @@ -75,7 +75,7 @@ services: PGDATA: /var/lib/postgresql/data/pgdata volumes: - postgres_data:/var/lib/postgresql/data - - ../../docs/postgres-schema.sql:/docker-entrypoint-initdb.d/001-schema.sql:ro + - ../../backend/app/db/sql/001_platform_runtime.sql:/docker-entrypoint-initdb.d/001-platform-runtime.sql:ro ports: - "${POSTGRES_PORT:-15432}:5432" networks: diff --git a/docs/deployment-plan.md b/docs/deployment-plan.md index fde215f..8a848b8 100644 --- a/docs/deployment-plan.md +++ b/docs/deployment-plan.md @@ -322,7 +322,7 @@ CUDA_VISIBLE_DEVICES=0,1,2,3 ## 10. 部署检查清单 -- PostgreSQL 已初始化 `docs/postgres-schema.sql`。 +- PostgreSQL 已初始化当前运行脚本 `backend/app/db/sql/001_platform_runtime.sql`;`docs/postgres-schema.sql` 作为目标架构设计,后续通过迁移体系逐步收敛。 - Redis 可连通。 - 后端 `GET /modelTF/health` 正常。 - Compute API 健康检查正常。