codebertBase / Dockerfile
Forrest99's picture
Update Dockerfile
a324382 verified
raw
history blame
739 Bytes
FROM python:3.9-slim
# 创建缓存目录并提前设置权限
RUN mkdir -p /app/.cache/huggingface && \
chown -R 1000:1000 /app && \
chmod -R 755 /app
# 安装系统依赖
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc python3-dev && \
rm -rf /var/lib/apt/lists/*
# 安装Python依赖
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 切换非root用户
USER 1000
# 复制代码
COPY --chown=1000:1000 app.py .
# 环境变量
ENV HF_HOME=/app/.cache/huggingface \
TRANSFORMERS_CACHE=/app/.cache/huggingface \
HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]