fix/ 修复后端dockerworkflow会跑两次alembic的问题

This commit is contained in:
Kevin
2026-04-01 16:14:38 +08:00
parent 53d9e003af
commit 43ef260ae2
5 changed files with 47 additions and 12 deletions

View File

@@ -37,8 +37,8 @@ USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
HEALTHCHECK --interval=15s --timeout=5s --start-period=120s --retries=6 \
CMD python -c "import http.client; conn = http.client.HTTPConnection('localhost', 8000); conn.request('GET', '/health'); r = conn.getresponse(); exit(0 if r.status == 200 else 1)" || exit 1
# 启动前执行 Alembic 迁移,再启动 uvicorn
CMD ["sh", "-c", "uv run alembic upgrade head && uv run uvicorn main:app --host 0.0.0.0 --port 8000"]
# Alembic 迁移放到 FastAPI startup带重试与日志入口仅启动 web 进程。
CMD ["sh", "-c", "uv run uvicorn main:app --host 0.0.0.0 --port 8000"]