Spaces:
Paused
Paused
File size: 721 Bytes
4e5a541 29f0660 4e5a541 29f0660 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # 使用轻量级的 Python 基础镜像
FROM python:3.10-slim
# 设置工作目录
WORKDIR /app
# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件并安装 Python 依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制项目代码
COPY . .
# 暴露应用端口(Hugging Face Spaces 默认使用 7860)
EXPOSE 7860
# 运行应用(优先使用 Hugging Face 注入的 PORT)
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]
|