From 6416441539ee6f5119c32f48966267f5cb65f891 Mon Sep 17 00:00:00 2001 From: liangguodong Date: Thu, 5 Mar 2026 18:58:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=91=E6=89=98?= =?UTF-8?q?=E7=AE=A1=E9=83=A8=E7=BD=B2=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/.dockerignore | 19 +++++++++++++++++++ server/Dockerfile | 19 +++++++++++++++++++ server/container.config.json | 26 ++++++++++++++++++++++++++ server/requirements.txt | 1 + 4 files changed, 65 insertions(+) create mode 100644 server/.dockerignore create mode 100644 server/Dockerfile create mode 100644 server/container.config.json diff --git a/server/.dockerignore b/server/.dockerignore new file mode 100644 index 0000000..059b1eb --- /dev/null +++ b/server/.dockerignore @@ -0,0 +1,19 @@ +# 忽略本地环境配置 +.env +.env.* + +# 忽略缓存 +__pycache__/ +*.pyc +*.pyo + +# 忽略git +.git/ +.gitignore + +# 忽略测试文件 +test_*.py + +# 忽略IDE +.idea/ +.vscode/ diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..9e8de7e --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.11-slim + +WORKDIR /app + +# 安装依赖 +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com + +# 复制代码 +COPY . . + +# 删除本地环境配置,使用容器环境变量 +RUN rm -f .env + +# 暴露端口 +EXPOSE 3000 + +# 启动命令 +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "3000"] diff --git a/server/container.config.json b/server/container.config.json new file mode 100644 index 0000000..05dc36e --- /dev/null +++ b/server/container.config.json @@ -0,0 +1,26 @@ +{ + "containerPort": 3000, + "dockerfilePath": "Dockerfile", + "buildDir": "", + "minNum": 0, + "maxNum": 10, + "cpu": 0.5, + "mem": 1, + "policyType": "cpu", + "policyThreshold": 60, + "envParams": { + "SERVER_HOST": "0.0.0.0", + "SERVER_PORT": "3000", + "DEBUG": "False", + "DB_HOST": "10.45.108.178", + "DB_PORT": "3306", + "DB_USER": "root", + "DB_PASSWORD": "!Lgd20020523", + "DB_NAME": "stardom_story", + "AI_SERVICE_ENABLED": "True", + "AI_PROVIDER": "deepseek", + "DEEPSEEK_API_KEY": "sk-a685e8a0e97e41e4b3cb70fa6fcc3af1", + "DEEPSEEK_BASE_URL": "https://api.deepseek.com/v1", + "DEEPSEEK_MODEL": "deepseek-chat" + } +} diff --git a/server/requirements.txt b/server/requirements.txt index b5e1ad1..e1952f7 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -8,3 +8,4 @@ pydantic==2.5.2 pydantic-settings==2.1.0 python-dotenv==1.0.0 python-multipart==0.0.6 +httpx==0.27.0