PyExecService / Dockerfile
StarrySkyWorld's picture
Create Dockerfile
41e63d9 verified
raw
history blame contribute delete
711 Bytes
# 使用官方轻量级 Python 镜像
FROM python:3.11-slim
# 避免 Python 输出被缓冲,日志能实时看到
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# 工作目录
WORKDIR /app
# 安装基础依赖(构建工具、可能需要的系统库)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 先复制依赖文件,利用 Docker 缓存
COPY requirements.txt .
# 安装 Python 依赖
RUN pip install -r requirements.txt
# 再复制代码
COPY app.py .
# HuggingFace Spaces 默认使用 7860 端口
EXPOSE 7860
# 启动 PES(FastAPI + Uvicorn)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]