This commit is contained in:
Joseph Hanson 2024-08-02 21:45:15 -05:00
parent 72dc22fa22
commit 56018e39f8
Signed by: jahanson
SSH key fingerprint: SHA256:vy6dKBECV522aPAwklFM3ReKAVB086rT3oWwiuiFG7o
8 changed files with 89 additions and 1 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use nix

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.direnv

View file

@ -0,0 +1,12 @@
---
version: "3"
tasks:
build:
desc: Build docker container
cmds:
- docker build -f Dockerfile-chainguard -t comfyui .
run:
desc: Run docker container
cmds:
- docker run -it --entrypoint /bin/bash comfyui

39
Dockerfile-chainguard Normal file
View file

@ -0,0 +1,39 @@
# Stage 1: Build
FROM chainguard/python:latest-dev AS builder
# 2.3.0-cuda12.1-cudnn8-runtime AS builder
# FROM cgr.dev/chainguard/pytorch-cuda12:latest AS builder
ARG TAG_VERSION=v0.0.2
USER root
ENV ROOT=/app
WORKDIR ${ROOT}
RUN mkdir -p /nonroot/.cache/pip
RUN --mount=type=cache,target=/nonroot/.cache/pip \
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
cd ${ROOT} && \
git checkout ${TAG_VERSION} && \
pip install -r requirements.txt
COPY . ${ROOT}
RUN chown -R nonroot.nonroot /app/
RUN chown -R nonroot.nonroot /nonroot/
RUN chmod u+x entrypoint.sh
# # Stage 2: Minimal Image
FROM cgr.dev/chainguard/pytorch-cuda12:latest
USER nonroot
ENV ROOT=/app
WORKDIR ${ROOT}
# RUN apk add python-${version}
ENV ROOT=/app
ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="${PYTHONPATH}:${ROOT}" CLI_ARGS="" PATH="${PATH}:${ROOT}"
# Copy the application from the builder stage
COPY --from=builder /app ${ROOT}
# And the pip cache
COPY --from=builder /nonroot /nonroot
EXPOSE 7860
ENTRYPOINT ["entrypoint.sh"]
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}

14
README.md Normal file
View file

@ -0,0 +1,14 @@
# README
## local dev
```sh
docker build -f Dockerfile-chainguard -t comfyui .
docker run -it --entrypoint /bin/bash comfyui
```
## remote dev
```sh
docker run -it --entrypoint /bin/bash jahanson/comfyui:latest
```

9
Taskfile.yaml Normal file
View file

@ -0,0 +1,9 @@
---
version: "3"
includes:
docker: .taskfiles/docker
tasks:
default:
cmds: ["task -l"]

View file

@ -6,7 +6,7 @@ mkdir -vp /data/config/comfy/custom_nodes
declare -A MOUNTS declare -A MOUNTS
MOUNTS["/root/.cache"]="/data/.cache" MOUNTS["/nonroot/.cache"]="/data/.cache"
MOUNTS["${ROOT}/input"]="/data/config/comfy/input" MOUNTS["${ROOT}/input"]="/data/config/comfy/input"
MOUNTS["${ROOT}/output"]="/output/comfy" MOUNTS["${ROOT}/output"]="/output/comfy"

12
shell.nix Normal file
View file

@ -0,0 +1,12 @@
# Shell for bootstrapping flake-enabled nix and home-manager
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
# Enable experimental features without having to specify the argument
NIX_CONFIG = "experimental-features = nix-command flakes";
nativeBuildInputs = with pkgs; [
lazydocker
pre-commit
go-task
];
}