FROM python:3.13-slim # Install uv COPY --from=ghcr.io/astral-sh/uv:0.8.13 /uv /bin/ # Set up user with ID 1000 (HF Spaces requirement) RUN useradd -m -u 1000 user # Switch to the user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR $HOME/app # Install system dependencies to speed up wheel building USER root RUN apt-get update && apt-get install -y \ gcc \ g++ \ libffi-dev \ libssl-dev \ build-essential \ curl \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Switch back to user USER user # Use copy link mode to avoid warnings with cache mounts ENV UV_LINK_MODE=copy # Copy the binary-shield directory structure COPY --chown=user . . # Install dependencies first (intermediate layer for better caching) # This layer will be cached and reused unless pyproject.toml changes # RUN uv sync --no-install-project --all-groups # Install the project itself (this layer changes more frequently) RUN uv sync --compile-bytecode --all-groups # Expose port 7860 (HF Spaces default) EXPOSE 7860 # Run the demo application CMD ["uv", "run", "python", "demo.py"]