Spaces:
Sleeping
Sleeping
| # Fetch — Docker Space image. | |
| # Python 3.11 is deliberate: stable, wide wheel coverage, avoids the | |
| # audioop removal in 3.13. | |
| FROM python:3.11-slim | |
| # Prevent .pyc files + force stdout/stderr to flush immediately so HF's | |
| # log viewer shows startup progress in real time. | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| # Cache HuggingFace model downloads in a writable path under the | |
| # non-root user's home. HF Spaces mounts this writable. | |
| HF_HOME=/home/user/.cache/huggingface \ | |
| TRANSFORMERS_CACHE=/home/user/.cache/huggingface | |
| # Minimal system deps. No ffmpeg, no libgl — we don't need audio or vision. | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # HF Spaces requires running as a non-root user (UID 1000). | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH=/home/user/.local/bin:$PATH | |
| WORKDIR /home/user/app | |
| # Install Python deps first for better layer caching. | |
| COPY --chown=user requirements.txt ./ | |
| RUN pip install --user --no-cache-dir -r requirements.txt | |
| # App code. | |
| COPY --chown=user app.py ./ | |
| COPY --chown=user static/ ./static/ | |
| # HF Spaces expects the app on port 7860. | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |