Spaces:
Sleeping
Sleeping
Download Dockerfile from AfanR/BackendBooki: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/AfanR/BackendBooki/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/AfanR/BackendBooki/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/AfanR/BackendBooki/resolve/main/Dockerfile
1.56 kB
| # Gunakan image Python 3.13 slim untuk performa ringan | |
| FROM python:3.13-slim | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| UV_SYSTEM_PYTHON=1 \ | |
| PATH="/app/.venv/bin:/home/user/.local/bin:$PATH" | |
| # Setup Non-Root User untuk Hugging Face Spaces (UID 1000) | |
| RUN useradd -m -u 1000 user | |
| # Install dependency sistem yang mungkin dibutuhkan dan hapus cache apt | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install uv menggunakan installer resminya untuk instalasi package super-cepat | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| # Gunakan /app sebagai direktori utama | |
| WORKDIR /app | |
| # Atur owner /app ke non-root user | |
| RUN chown -R user:user /app | |
| # Pindah eksekusi ke dalam context user | |
| USER user | |
| # Copy pyproject.toml, uv.lock, dan README.md terlebih dahulu untuk memanfaatkan layer caching Docker | |
| COPY --chown=user:user pyproject.toml uv.lock README.md ./ | |
| # Install dependensi (termasuk uvicorn dan asgiref sesuai pyproject) | |
| RUN uv sync --frozen --no-dev --no-install-project | |
| # Copy seluruh source code repository, asumsikan dataset statis yang berada di folder /data | |
| # dan pastikan ownership user 1000 untuk mencegah Error saat runtime | |
| COPY --chown=user:user . . | |
| # Expose port untuk dokumentasi (meski HF Spaces merutekan port otomatis ke 7860) | |
| EXPOSE 7860 | |
| # Perintah utama untuk meluncurkan ASGI backend via Uvicorn pada port 7860 | |
| CMD ["uv", "run", "uvicorn", "app:asgi_app", "--host", "0.0.0.0", "--port", "7860"] | |