فهرست منبع

fix(docker): 修复 Docker Compose 端口映射配置

修改内容:
- 修复主服务 (q2api) 的端口映射,将容器内部端口固定为 8000
- 修复 account-feeder 服务的端口映射,将容器内部端口固定为 8001
- 更新 healthcheck 配置使用固定的内部端口

问题说明:
之前的配置在端口映射和 healthcheck 中都使用了环境变量 \,
这会导致容器内部端口也随环境变量变化,造成服务无法正常访问。

解决方案:
- 保持宿主机端口可通过环境变量配置(\)
- 容器内部端口固定为标准端口(8000/8001)
- healthcheck 使用固定的内部端口进行健康检查

影响范围:
- docker-compose.yml: 主 API 服务配置
- account-feeder/docker-compose.yml: 账号供给服务配置
CassiopeiaCode 4 ماه پیش
والد
کامیت
0fa875e446
2فایلهای تغییر یافته به همراه5 افزوده شده و 5 حذف شده
  1. 2 2
      account-feeder/docker-compose.yml
  2. 3 3
      docker-compose.yml

+ 2 - 2
account-feeder/docker-compose.yml

@@ -7,12 +7,12 @@ services:
       dockerfile: Dockerfile
     container_name: q2api-account-feeder
     ports:
-      - "${FEEDER_PORT:-8001}:${FEEDER_PORT:-8001}"
+      - "${FEEDER_PORT:-8001}:8001"
     env_file:
       - .env
     restart: unless-stopped
     healthcheck:
-      test: ["CMD", "curl", "-f", "http://localhost:${FEEDER_PORT:-8001}/health"]
+      test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
       interval: 30s
       timeout: 10s
       retries: 3

+ 3 - 3
docker-compose.yml

@@ -7,15 +7,15 @@ services:
       dockerfile: Dockerfile
     container_name: q2api
     ports:
-      - "${PORT:-8000}:${PORT:-8000}"
+      - "${PORT:-8000}:8000"
     env_file:
       - .env
     volumes:
       - ./:/app
     restart: unless-stopped
-    command: uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000} --workers 4
+    command: uvicorn app:app --host 0.0.0.0 --port 8000 --workers 4
     healthcheck:
-      test: ["CMD", "curl", "-f", "http://localhost:${PORT:-8000}/healthz"]
+      test: ["CMD", "curl", "-f", "http://localhost:8000/healthz"]
       interval: 30s
       timeout: 10s
       retries: 3