FROM rocm/pytorch:rocm6.2_ubuntu22.04_py3.10_pytorch_release_2.3.0

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV GIT_TERMINAL_PROMPT=0
ENV HSA_OVERRIDE_GFX_VERSION=11.0.0

# System dependencies
RUN apt-get update && apt-get install -y \
    git wget ffmpeg \
    libsndfile1 \
    pkg-config libavformat-dev libavcodec-dev libavdevice-dev \
    libavutil-dev libswscale-dev libswresample-dev libavfilter-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Clone ComfyUI
RUN git clone https://github.com/comfyanonymous/ComfyUI.git

WORKDIR /app/ComfyUI

# ComfyUI dependencies (torch already included in base image)
RUN pip install --no-cache-dir -r requirements.txt

# ComfyUI-Manager
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager
RUN pip install --no-cache-dir -r custom_nodes/ComfyUI-Manager/requirements.txt

# AudioCraft
RUN pip install --no-cache-dir audiocraft

EXPOSE 8188

CMD ["python", "main.py", "--listen", "0.0.0.0", "--port", "8188"]
