File size: 1,757 Bytes
f3b96de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
FROM python:3.11.12-slim
#3.10-slim


ENV NUMBA_CACHE_DIR=/tmp
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
ENV HF_HUB_CACHE=/tmp/huggingface/hub

WORKDIR /app



RUN mkdir -p /app/tmp && chmod -R 777 /app/tmp
RUN mkdir -p /app/tmp/huggingface/token && chmod -R 777 /app/tmp/huggingface/token
# Install git, build tools, and dependencies
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    cmake \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    && rm -rf /var/lib/apt/lists/*
    

# Clone the repository
RUN git clone https://github.com/Stability-AI/stable-fast-3d.git

# Install PyTorch first (needed for the local package builds)
RUN pip install --no-cache-dir torch==2.6.0
#2.1.0

# Install Python dependencies (except local packages)
# Create a modified requirements file without the local packages
RUN grep -v "^\./" stable-fast-3d/requirements.txt > modified_requirements.txt && \
    pip install --no-cache-dir -r modified_requirements.txt

# Install the local packages
# First texture_baker
WORKDIR /app/stable-fast-3d/texture_baker
RUN pip install -e .
# Then uv_unwrapper
WORKDIR /app/stable-fast-3d/uv_unwrapper
RUN pip install -e .
# Return to app directory
WORKDIR /app
# Copy the FastAPI application code
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir transformers==4.38.1 huggingface_hub==0.20.3


RUN useradd -m -u 1000 user

# Switch to the "user" user
USER user

COPY --chown=user app/ app/
COPY --chown=user main.py .

# Expose the port the app will run on
EXPOSE 7860


# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]