28 lines
671 B
Docker
28 lines
671 B
Docker
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# 使用国内 Debian 镜像源加速
|
|
RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装 Python 依赖
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
|
|
|
# 复制项目代码
|
|
COPY . .
|
|
|
|
# 创建上传目录
|
|
RUN mkdir -p /app/uploads
|
|
|
|
EXPOSE 8000
|
|
|
|
# 开发模式:热重载
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|