Spaces:
Running
Running
File size: 753 Bytes
6e56713 7f7b229 1e8a35b 7b51116 8523cd0 73e30a3 1e8a35b 0a5b8ec 73e30a3 7b51116 73e30a3 0be888b 7b0b702 73e30a3 7b0b702 1e8a35b 73e30a3 7b51116 0a5b8ec 1e8a35b |
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 30 31 |
FROM python:3.10-slim
# 设置全局环境变量
ENV PYTHONUNBUFFERED=1 \
PATH="/home/appuser/.local/bin:${PATH}"
# 安装系统依赖
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc python3-dev && \
rm -rf /var/lib/apt/lists/*
# 创建应用用户
RUN useradd -m appuser && \
mkdir -p /model-cache && \
chown -R appuser:appuser /model-cache
# 切换用户
USER appuser
WORKDIR /app
# 安装Python依赖(单条RUN指令)
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir gunicorn==21.2.0 && \
pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY app.py .
EXPOSE 7860
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"] |