FROM python:3.12.1-slim-bookworm # Install uv by copying it directly from its container image (much faster and smaller than pip) COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv # Install uv (the fast package manager) # This step is technically redundant if the COPY above works, but we'll keep it. RUN pip install uv # Set the working directory WORKDIR /app # Copy dependency files COPY pyproject.toml uv.lock ./ # Install dependencies from the lock file RUN uv sync --frozen --no-cache # The .venv is located inside the WORKDIR /app ENV PATH="/app/.venv/bin:$PATH" # ==================================== # Copy the FastAPI app and model COPY predict.py model.bin ./ # Expose port (optional but good practice, 7860 for HF Spaces) EXPOSE 7860 # Start the FastAPI app with uvicorn ENTRYPOINT ["uvicorn", "predict:app", "--host", "0.0.0.0", "--port", "7860"]