Spaces:
Sleeping
Sleeping
File size: 979 Bytes
061676c 06c095f 061676c dc24051 e2e640c 061676c 06c095f 061676c 62d49a1 dc24051 061676c dc24051 62d49a1 061676c dc24051 06c095f 061676c dc24051 06c095f 061676c 62d49a1 061676c dc24051 06c095f 061676c 62d49a1 061676c 06c095f |
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 32 33 34 35 36 37 38 39 40 |
# ๐น Base image
FROM python:3.10-slim
# ๐น Create Hugging Face-compliant non-root user
RUN useradd -m -u 1000 user
# ๐น Set environment variables
ENV HOME=/home/user \
APP_HOME=/home/user/app \
HF_HOME=/home/user/.hf_home \
OMP_NUM_THREADS=8 # โ
Use all 8 vCPUs
# ๐น Set working directory
WORKDIR $APP_HOME
# ๐น Install system dependencies (root)
USER root
RUN apt-get update && apt-get install -y \
git curl \
&& rm -rf /var/lib/apt/lists/*
# ๐น Install Python dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
# ๐น Copy app code and give ownership to non-root user
COPY --chown=user:user . .
# ๐น Ensure HF model cache dir is writable
RUN mkdir -p $HF_HOME && chown -R user:user $HF_HOME
# ๐น Switch to non-root user (required by HF Spaces)
USER user
# ๐น Expose the FastAPI port
EXPOSE 7860
# ๐น Start your app
CMD ["python", "app.py"]
|