docker-entrypoint.sh
770 Bytes
#!/bin/sh
# LLM Call Platform Docker 启动脚本
set -e
# 等待数据库就绪
echo "等待数据库..."
if [ -n "$DB_HOST" ] && [ -n "$DB_PORT" ]; then
while ! nc -z "$DB_HOST" "$DB_PORT"; do
sleep 1
done
fi
echo "数据库就绪"
# 运行数据库迁移(首次创建表)
echo "运行数据库迁移..."
cd /app/backend
python -c "
from app.core.database import engine, Base
from app.models import ModelProvider, ModelAccountConfig
import asyncio
async def init():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
print('数据库表创建完成')
asyncio.run(init())
"
# 启动 FastAPI 应用
echo "启动 LLM Call Platform..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8011 --workers 4