File size: 1,226 Bytes
5272088
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e061fd
5272088
 
6e061fd
5272088
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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"]