File size: 2,123 Bytes
d62394f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99943dd
 
d62394f
99943dd
 
 
 
d62394f
090544c
d62394f
090544c
 
d62394f
 
 
 
6dddb70
 
 
d62394f
 
 
090544c
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Use NVIDIA CUDA image that matches PyTorch's CUDA 12.4 compilation
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04

# Install Python 3.10 and dependencies with cache mounts
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && apt-get install -y \
    python3.10 \
    python3.10-venv \
    python3.10-dev \
    python3-pip \
    git \
    build-essential \
    curl \
    ninja-build \
    wget

# Create symlinks for python
RUN ln -sf /usr/bin/python3.10 /usr/bin/python3 && \
    ln -sf /usr/bin/python3.10 /usr/bin/python

# Set CUDA environment variables for runtime
ENV CUDA_HOME=/usr/local/cuda \
    PATH=/usr/local/cuda/bin:$PATH \
    LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

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

# Set up user with ID 1000 (required for HF Spaces)
RUN useradd -m -u 1000 user

# Switch to user and set working directory
USER user
WORKDIR /home/user/app

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONUNBUFFERED=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_SERVER_PORT=7860 \
    UV_CACHE_DIR=/home/user/.cache/uv

# Copy Docker-specific dependency files
COPY --chown=user pyproject.docker.toml ./pyproject.toml

# Download pre-built gsplat wheel from models repository
RUN mkdir -p wheels && \
    wget -O wheels/gsplat-0.1.0-cp310-cp310-linux_x86_64.whl \
    "https://huggingface.co/blanchon/image-gs-models-utils/resolve/main/gsplat-0.1.0-cp310-cp310-linux_x86_64.whl"

# Create virtual environment and install dependencies
RUN --mount=type=cache,target=/tmp/uv-cache,sharing=locked,uid=1000,gid=1000 \
    UV_CACHE_DIR=/tmp/uv-cache uv sync --no-dev && \
    uv venv .venv

# Copy the rest of the application
COPY --chown=user . .

# Ensure Docker-specific pyproject.toml is used at runtime
COPY --chown=user pyproject.docker.toml ./pyproject.toml

# Expose port 7860 (default for HF Spaces)
EXPOSE 7860

# Activate venv and launch the Gradio app directly
CMD [".venv/bin/python", "gradio_app.py"]