Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files12345678910111213141516171 unmodified line19202122232425262728293031FROM python:3.10-slim# 设置环境变量ENV TRANSFORMERS_CACHE=/model-cache \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 adduser --disabled-password --gecos "" appuser && \mkdir -p /model-cache && \chown -R appuser:appuser /model-cache1 unmodified lineUSER appuserWORKDIR /app# 安装Python依赖COPY requirements.txt .RUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir -r requirements.txt# 复制应用代码COPY app.py .EXPOSE 8080CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--timeout", "120", "app:app"]1234567891011121314151617181 unmodified line20212223242526272829303132333435363738# 使用Python官方镜像FROM python:3.10-slim# 设置环境变量ENV HF_HOME=/model-cache \PYTHONUNBUFFERED=1 \PORT=7860 # Hugging Face强制使用7860端口# 安装系统依赖RUN apt-get update && \apt-get install -y --no-install-recommends gcc python3-dev && \rm -rf /var/lib/apt/lists/*# 创建非root用户RUN useradd -m appuser && \mkdir -p /model-cache && \chown -R appuser:appuser /model-cache1 unmodified lineUSER appuserWORKDIR /app# 复制依赖文件COPY requirements.txt .# 安装依赖并预下载模型RUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir -r requirements.txt && \python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('flax-sentence-embeddings/st-codesearch-distilroberta-base')"# 复制应用代码COPY app.py .# 暴露Hugging Face强制端口EXPOSE 7860# 启动命令(必须使用7860端口)CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "600", "app:app"]
Dockerfile+15-8