File size: 947 Bytes
928a62e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.13-slim

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Change the working directory to the `app` directory
WORKDIR /app

# Install dependencies (separate layer for better caching)
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=type=bind,source=uv.lock,target=uv.lock \
    --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
    uv sync --locked --no-install-project

# Copy the project into the image
COPY . /app

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked

# Expose port 7860 for Hugging Face Spaces
EXPOSE 7860

# Set port environment variable for Hugging Face Spaces
ENV PORT=7860

# Set UV cache directory to writable location for non-root user
ENV UV_CACHE_DIR=/app/.cache/uv

# Create cache directory with proper permissions
RUN mkdir -p /app/.cache/uv && chmod -R 777 /app/.cache

# Run the server
CMD ["uv", "run", "server.py"]