Skip to content

Commit

Permalink
Initial commit for ComfyUI Runpod worker
Browse files Browse the repository at this point in the history
  • Loading branch information
anuvgupta committed Jan 16, 2025
0 parents commit 1daaaf0
Show file tree
Hide file tree
Showing 16 changed files with 1,306 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.git
*.gitignore

env/
.env

__pycache__
*.pyc
*.pyo
*.pyd
.Python
55 changes: 55 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker Build and Push Container

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
# TODO: Enable this step if not using network volume
# - name: Free disk space
# run: |
# df -h
# sudo rm -rf /usr/share/dotnet
# sudo rm -rf /usr/local/lib/android
# sudo rm -rf /opt/ghc
# sudo rm -rf /opt/hostedtoolcache
# df -h

- uses: actions/checkout@v3
with:
ref: main

- name: Generate version number
id: version
run: |
echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker-container
buildkitd-flags: --debug

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build container and push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO_NAME }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO_NAME }}:${{ steps.version.outputs.VERSION }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO_NAME }}:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO_NAME }}:buildcache,mode=max
platforms: linux/amd64
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# git ignore

# system
.DS_Store

# python
venv
__pycache__

# env
.env
64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# dockerfile

FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04

WORKDIR /

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
PIP_PREFER_BINARY=1 \
PYTHONUNBUFFERED=1 \
CUDA_HOME=/usr/local/cuda \
PATH=/usr/local/cuda/bin:/opt/venv/bin:$PATH \
ENVIRONMENT=PRODUCTION \
COMFYUI_ROOT=/comfyui

# Install Python, system dependencies, and CUDA
RUN apt-get update && \
apt-get install -y --no-install-recommends \
bash \
git \
python3.10.16 \
python3.10.16-venv \
python3-pip \
libgl1 \
libglib2.0-0 \
wget && \
rm -rf /var/lib/apt/lists/*

# Create virtual environment for Python and install requirements
RUN python3.10 -m venv /opt/venv && \
/opt/venv/bin/pip install --upgrade pip

# Copy the Python dependencies (requirements.txt) and install
RUN /opt/venv/bin/pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

# Clone ComfyUI and install its dependencies
RUN git clone https://github.com/comfyanonymous/ComfyUI.git ${COMFYUI_ROOT} && \
cd ${COMFYUI_ROOT} && \
/opt/venv/bin/pip install --no-cache-dir -r requirements.txt


# download models
# SD Classic 1.5
# RUN wget --show-progress --progress=dot:giga -O /comfyui/models/checkpoints/v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors
# SDXL Lightning 4-step
# RUN wget --show-progress --progress=dot:giga -O /comfyui/models/checkpoints/sdxl_lightning_4step.safetensors https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_4step.safetensors
# SDXL Lightning 8-step
# RUN wget --show-progress --progress=dot:giga -O /comfyui/models/checkpoints/sdxl_lightning_8step.safetensors https://huggingface.co/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_8step.safetensors
# Juggernaut XL Lightning, Version XI
# RUN wget --show-progress --progress=dot:giga -O /comfyui/models/checkpoints/juggernautXL_juggXILightningByRD.safetensors https://civitai.com/api/download/models/920957?type=Model&format=SafeTensor&size=full&fp=fp16
# TODO: Add your models here if not using network volume


# Copy the Python dependencies (requirements.txt) and install
COPY requirements.txt /requirements.txt
RUN /opt/venv/bin/pip install --no-cache-dir -r /requirements.txt

# Copy application code
RUN mkdir -p /app
COPY src/ /app/
RUN chmod +x /app/main.sh

# Set the final command
CMD ["/app/main.sh"]
Loading

0 comments on commit 1daaaf0

Please sign in to comment.