3D_Model_AI / Dockerfile
Sammi1211's picture
1
f3b96de
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"]