22 lines
492 B
Docker
22 lines
492 B
Docker
# 后端 Python 服务
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# 配置 pip 使用阿里云镜像
|
|
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
|
|
pip config set global.trusted-host mirrors.aliyun.com
|
|
|
|
# 安装依赖
|
|
COPY backend/requirements.txt ./
|
|
RUN pip install --no-cache-dir -r requirements.txt --timeout 120
|
|
|
|
# 复制源码
|
|
COPY backend/ ./
|
|
|
|
# 暴露端口
|
|
EXPOSE 8000
|
|
|
|
# 启动命令
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|