增加docker文件

This commit is contained in:
zhl
2026-09-21 20:43:32 +08:00
parent ef88fbdbe9
commit a061f1ab8b
5 changed files with 100 additions and 6 deletions
+18
View File
@@ -0,0 +1,18 @@
# 基础镜像
FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 先复制 requirements.txt 并安装依赖,利用 Docker 镜像缓存(使用清华镜像源加速)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 复制整个项目代码到容器
COPY . .
# 暴露端口
EXPOSE 8005
# 启动命令:运行 main.py 中的 FastAPI 应用
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"]