# Hunyuan3D-2 — image to 3D mesh with PBR textures
# Community Dockerfile based on repo issues #125, #122
# Target: RTX 3080 (10GB VRAM) with mini-turbo variant
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04

LABEL name="hunyuan3d-2" maintainer="herby"

ENV DEBIAN_FRONTEND=noninteractive

# System dependencies
RUN apt-get update && apt-get install -y \
    git wget curl vim \
    build-essential cmake \
    python3 python3-pip python3-dev \
    libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 \
    libegl1-mesa-dev libgles2-mesa-dev \
    && rm -rf /var/lib/apt/lists/*

# Set python3 as default
RUN ln -sf /usr/bin/python3 /usr/bin/python

WORKDIR /workspace

# Copy repo contents
COPY . /workspace/Hunyuan3D-2
WORKDIR /workspace/Hunyuan3D-2

# Install PyTorch with CUDA 12.4 support
RUN pip install --no-cache-dir \
    torch torchvision torchaudio \
    --index-url https://download.pytorch.org/whl/cu124

# Install project requirements
RUN pip install --no-cache-dir -r requirements.txt

# Install additional deps that may be missing from upstream requirements
RUN pip install --no-cache-dir \
    gradio \
    onnxruntime \
    flash-attn --no-build-isolation || true

# Install custom ops if available
RUN cd /workspace/Hunyuan3D-2 && \
    pip install -e . || true

# Model cache directory
VOLUME /root/.cache/hy3dgen

EXPOSE 8080

# Default command — overridden by compose.yml command
CMD ["python3", "gradio_app.py", "--host", "0.0.0.0", "--port", "8080"]
