主干Ai实验室后端项目

This commit is contained in:
BBIT-Kai
2025-09-05 09:37:47 +08:00
parent aa25f914ab
commit 4a0e79b35a
25 changed files with 628 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
# 使用官方 Python 镜像
FROM python:3.10-slim
# 设置工作目录
WORKDIR /app
# 复制依赖文件
COPY requirements.txt .
# 更新系统源,安装 PostgreSQL 和 ODBC 依赖,以及微软 SQL Server 驱动
# 安装基础依赖和 Microsoft ODBC 驱动依赖
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq5 \
unixodbc \
curl \
gnupg \
apt-transport-https \
lsb-release && \
# 导入微软 GPG key(使用 keyrings 方式)
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/microsoft.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main" > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \
rm -rf /var/lib/apt/lists/*
# 安装 Python 依赖
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
# 复制项目代码
COPY app/ .
# 对外暴露端口(FastAPI 默认 8000
EXPOSE 8000
# 启动命令(使用 uvicorn 启动 FastAPI
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "13011"]