rsnarsna
fix(storage): resolve storage PermissionError with resilient tempdir fallback and ensure user ownership in Dockerfile
4c6e578 Download Dockerfile from Rsnarsna/auto: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Rsnarsna/auto/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/Dockerfile
1.63 kB
| # ─── Production Dockerfile for ALLI Backend (FastAPI + Uvicorn) ─────────── | |
| # Optimized for Hugging Face Spaces (UID 1000 / port 7860), Koyeb, Render, & Docker Compose | |
| FROM python:3.12-slim | |
| # Prevent Python from writing .pyc files and enable unbuffered logging | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PORT=7860 \ | |
| HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Install runtime utilities & security certificates | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create standard unprivileged non-root user (UID 1000) required by Hugging Face Spaces | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /home/user/app | |
| # Install Python dependencies first for optimal Docker layer caching | |
| COPY --chown=user:user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy application source code with user ownership | |
| COPY --chown=user:user . . | |
| # Ensure storage directory exists with write permissions for user | |
| RUN mkdir -p /home/user/app/storage && \ | |
| chown -R user:user /home/user | |
| USER user | |
| # Health check to ensure service readiness | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ | |
| CMD curl -f http://127.0.0.1:${PORT:-7860}/health || exit 1 | |
| # Expose ports (7860 for Hugging Face Spaces, 8001 for local / docker-compose) | |
| EXPOSE 7860 | |
| EXPOSE 8001 | |
| # Start pure traditional FastAPI Uvicorn engine (dynamically adapts to $PORT) | |
| CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}"] | |