Spaces:
Running
Running
| # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| # you will also find guides on how best to write your Dockerfile | |
| FROM python:3.13-slim | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| RUN useradd -m -u 1000 user | |
| RUN mkdir -p /model && chown user:user /model | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Enable bytecode compilation for faster startup | |
| ENV UV_COMPILE_BYTECODE=1 | |
| # Use hard links for cached packages to save space | |
| ENV UV_LINK_MODE=copy | |
| # Copy dependency files first (for layer caching) | |
| COPY --chown=user pyproject.toml uv.lock ./ | |
| # Install dependencies | |
| RUN uv sync --frozen --no-install-project --no-dev | |
| # Model download (to a path that won't be overwritten by COPY . /app) | |
| RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \ | |
| uv run hf download \ | |
| --token=$(cat /run/secrets/HF_TOKEN) \ | |
| --local-dir=/model \ | |
| --repo-type=model ObinnaOkpolu/ct2-nllb-int8-its | |
| # Layer: app code | |
| COPY --chown=user . /app | |
| RUN uv sync --frozen --no-dev | |
| CMD ["uv", "run", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |