From 4340541358053878f787344c3e65f99ad11b278b Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 15 May 2024 11:00:13 -0400 Subject: [PATCH 1/4] add docker compose --profile syntax to startup --- README.md | 47 +++++---------- docker-compose.yml | 140 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 136 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index a145ec2..a5a663f 100644 --- a/README.md +++ b/README.md @@ -28,43 +28,26 @@ Unraid template available on [superboki's Repository](https://github.com/superbo ## Choosing a Project -Use the environmental variable `WEBUI_VERSION` to choose which [project](#projects) to install and use based on the number in the **WEBUI** column. [easy diffusion](https://github.com/easydiffusion/easydiffusion) (`01`) is installed if none is specified. - -Example: To use SD.Next => `WEBUI_VERSION=04` - ``` -docker run ... -e WEBUI_VERSION=04 ... holaflenain/stable-diffusion -``` - -or modify `WEBUI_VERSION` in [docker-compose.yml](/docker-compose.yml) - -## Docker Notes - -### Using PUID and PGID - -If you are - -* running on a **linux host** (ie unraid) and -* **not** using [rootless containers with Podman](https://developers.redhat.com/blog/2020/09/25/rootless-containers-with-podman-the-basics#why_podman_) +docker compose --profile easy-diffusion up # http://:9001 +docker compose --profile automatic1111 up # http://:9002 +docker compose --profile forge up # http://:9022 +docker compose --profile invoke-ai up # http://:9003 +docker compose --profile sd-next up # http://:9004 +docker compose --profile comfy-ui up # http://:9005 +docker compose --profile fooocus up # http://:9006 +docker compose --profile stable-swarm up # http://:9007 +docker compose --profile lama-cleaner up # http://:9050 +docker compose --profile face-fusion up # http://:9051 +docker compose --profile kohya up # http://:9070 -then you must set the [environmental variables **PUID** and **PGID**.](https://docs.linuxserver.io/general/understanding-puid-and-pgid) in the container in order for it to generate files/folders your normal user can interact it. - -Run these commands from your terminal - -* `id -u` -- prints UID for **PUID** -* `id -g` -- prints GID for **PGID** - -Then add to your docker command like so: - -```shell -docker run -d ... -e "PUID=1000" -e "PGID=1000" ... holaflenain/stable-diffusion ``` -or substitute them in [docker-compose.yml](/docker-compose.yml) +or -### Docker Compose - -Reference [docker-compose.yml](/docker-compose.yml) which uses Easy-Diffusion as an example. +``` +docker compose up # to run all the services at once +``` ## Directory Structure diff --git a/docker-compose.yml b/docker-compose.yml index 339531b..7aadb30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,122 @@ -version: '3.1' +x-service: &default-service + image: holaflenain/stable-diffusion:latest + runtime: nvidia + volumes: + - '/data/stable-diffusion:/config:rw' + +x-environment: &default-environment + NVIDIA_VISIBLE_DEVICES: all + TZ: ${TZ:-America/New_York} + PUID: ${PUID:-1000} + PGID: ${PGID:-1000} + services: - stable-diffusion-test: - image: holaflenain/stable-diffusion:latest - container_name: stable-diffusion - environment: - - WEBUI_VERSION=01 - - NVIDIA_VISIBLE_DEVICES=all - - TZ=Europe/Paris - - PUID=1000 - - PGID=1000 - ports: - - '9000:9000/tcp' - volumes: - - '/my/own/datadir:/config:rw' - # or specify individual dirs - #- '/my/own/datadir:/config:rw' # config/program dir - #- '/my/own/datadir/outputs:/config/outputs:rw' - #- '/my/own/datadir/cache:/config/cache:rw' - runtime: nvidia \ No newline at end of file + stable-diffusion-easy-diffusion: + <<: *default-service + profiles: [easy-diffusion] + container_name: stable-diffusion-easy-diffusion + environment: + <<: *default-environment + WEBUI_VERSION: '00' + ports: + - 9001:9000/tcp + + stable-diffusion-automatic1111: + <<: *default-service + profiles: [automatic1111] + container_name: stable-diffusion-automatic1111 + environment: + <<: *default-environment + WEBUI_VERSION: '02' + ports: + - 9002:9000/tcp + + stable-diffusion-forge: + <<: *default-service + profiles: [forge] + container_name: stable-diffusion-forge + environment: + <<: *default-environment + WEBUI_VERSION: '02.forge' + ports: + - 9022:9000/tcp + + stable-diffusion-invoke-ai: + <<: *default-service + profiles: [invoke-ai] + container_name: stable-diffusion-invoke-ai + environment: + <<: *default-environment + WEBUI_VERSION: '03' + ports: + - 9003:9000/tcp + + stable-diffusion-sd-next: + <<: *default-service + profiles: [sd-next] + container_name: stable-diffusion-sd-next + environment: + <<: *default-environment + WEBUI_VERSION: '04' + ports: + - 9004:9000/tcp + + stable-diffusion-comfy-ui: + <<: *default-service + profiles: [comfy-ui] + container_name: stable-diffusion-comfy-ui + environment: + <<: *default-environment + WEBUI_VERSION: '05' + ports: + - 9005:9000/tcp + + stable-diffusion-fooocus: + <<: *default-service + profiles: [fooocus] + container_name: stable-diffusion-fooocus + environment: + <<: *default-environment + WEBUI_VERSION: '06' + ports: + - 9006:9000/tcp + + stable-diffusion-stable-swarm: + <<: *default-service + profiles: [stable-swarm] + container_name: stable-diffusion-stable-swarm + environment: + <<: *default-environment + WEBUI_VERSION: '07' + ports: + - 9007:9000/tcp + + stable-diffusion-lama-cleaner: + <<: *default-service + profiles: [lama-cleaner] + container_name: stable-diffusion-lama-cleaner + environment: + <<: *default-environment + WEBUI_VERSION: '50' + ports: + - 9050:9000/tcp + + stable-diffusion-face-fusion: + <<: *default-service + profiles: [face-fusion] + container_name: stable-diffusion-face-fusion + environment: + <<: *default-environment + WEBUI_VERSION: '51' + ports: + - 9051:9000/tcp + + stable-diffusion-kohya: + <<: *default-service + profiles: [kohya] + container_name: stable-diffusion-kohya + environment: + <<: *default-environment + WEBUI_VERSION: '51' + ports: + - 9070:9000/tcp \ No newline at end of file From ba25cad315725d5781f642109c708a5f53836ac5 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 15 May 2024 15:34:31 -0400 Subject: [PATCH 2/4] fix mapping issues in docker-compose.yml --- README.md | 2 +- docker-compose.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a5a663f..6722b11 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Unraid template available on [superboki's Repository](https://github.com/superbo ``` docker compose --profile easy-diffusion up # http://:9001 -docker compose --profile automatic1111 up # http://:9002 +docker compose --profile automatic up # http://:9002 docker compose --profile forge up # http://:9022 docker compose --profile invoke-ai up # http://:9003 docker compose --profile sd-next up # http://:9004 diff --git a/docker-compose.yml b/docker-compose.yml index 7aadb30..12a83d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,14 +17,14 @@ services: container_name: stable-diffusion-easy-diffusion environment: <<: *default-environment - WEBUI_VERSION: '00' + WEBUI_VERSION: '01' ports: - 9001:9000/tcp - stable-diffusion-automatic1111: + stable-diffusion-automatic: <<: *default-service - profiles: [automatic1111] - container_name: stable-diffusion-automatic1111 + profiles: [automatic] + container_name: stable-diffusion-automatic environment: <<: *default-environment WEBUI_VERSION: '02' @@ -117,6 +117,6 @@ services: container_name: stable-diffusion-kohya environment: <<: *default-environment - WEBUI_VERSION: '51' + WEBUI_VERSION: '70' ports: - 9070:9000/tcp \ No newline at end of file From e22db71a197f12a61f0359139a16ff061f783b15 Mon Sep 17 00:00:00 2001 From: Mike Glenn <219478+ilude@users.noreply.github.com> Date: Thu, 16 May 2024 10:35:32 -0400 Subject: [PATCH 3/4] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6722b11..439212d 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ docker compose --profile kohya up # http://:9070 ``` -or +or +( Although not recommended as it will requires significant system resources, 64GB+ system memory and at bare minimum 16GB VRAM card, you have been warned! ) ``` docker compose up # to run all the services at once From dc35e4d4715ebd33135d2b786bc0555d43b1cd3e Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 16 May 2024 11:41:12 -0400 Subject: [PATCH 4/4] add makefile and update README.md --- .gitignore | 2 ++ Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 29 +++++++++++++++++++++++++++++ docker-compose.yml | 26 +++++++++++++------------- 4 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad60b67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +data/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8ea07d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# get the current machines +export HOSTIP := $(shell ip route get 1.1.1.1 | grep -oP 'src \K\S+') +export PUID := $(shell id -u) +export PGID := $(shell id -g) + +# Parse the available profiles from the docker-compose.yml +AVAILABLE_PROFILES := $(shell grep -oP 'profiles:\s*\[\K[^\]]+' docker-compose.yml | sed 's/\s*//g' | tr '\n' ' ') + +# Include .env variable in the current environment +ifneq (,$(wildcard ./.env)) + include .env + export +endif + +# Default target +.DEFAULT_GOAL := help +.PHONY: help up down start stop logs + +# Help target +help: + @echo "Available targets:" + @echo " up [profile] Start the specified profile (e.g., make up fooocus)" + @echo " down [profile] Stop the specified profile (e.g., make down fooocus)" + @echo " help Show this help message" + +# up target +up: + docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) up + +# down/stop target +down: stop +stop: + docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) down + +# start target +start: + docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) up -d + +logs: + docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) logs -f + +# Allow extra arguments for the up and down targets +%: + @: diff --git a/README.md b/README.md index 439212d..f3a7bca 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,35 @@ or docker compose up # to run all the services at once ``` +## Make + +alternatively you can use make to start and stop the services + +there are two variations + +``` +# will start the service detached from the terminal (running in the background) +make start + +# will start the service and leave its output attached to the terminal +make up +``` +Here is a complete list for starting services +``` +make start easy-diffusion # http://:9001 +make start automatic # http://:9002 +make start forge # http://:9022 +make start invoke-ai # http://:9003 +make start sd-next # http://:9004 +make start comfy-ui # http://:9005 +make start fooocus # http://:9006 +make start stable-swarm # http://:9007 +make start lama-cleaner # http://:9050 +make start face-fusion # http://:9051 +make start kohya # http://:9070 +``` + + ## Directory Structure Each interface has its own folder : diff --git a/docker-compose.yml b/docker-compose.yml index 12a83d7..2a2680d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,10 @@ x-service: &default-service image: holaflenain/stable-diffusion:latest runtime: nvidia volumes: - - '/data/stable-diffusion:/config:rw' + - "${STABLE_DIFFUSION_DATA_DIRECTORY:-./data/stable-diffusion}:/config:rw" x-environment: &default-environment - NVIDIA_VISIBLE_DEVICES: all + NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all} TZ: ${TZ:-America/New_York} PUID: ${PUID:-1000} PGID: ${PGID:-1000} @@ -19,7 +19,7 @@ services: <<: *default-environment WEBUI_VERSION: '01' ports: - - 9001:9000/tcp + - ${EASY_DIFFUSION_PORT:-9001}:9000/tcp stable-diffusion-automatic: <<: *default-service @@ -29,7 +29,7 @@ services: <<: *default-environment WEBUI_VERSION: '02' ports: - - 9002:9000/tcp + - ${AUTOMATIC_PORT:-9002}:9000/tcp stable-diffusion-forge: <<: *default-service @@ -39,7 +39,7 @@ services: <<: *default-environment WEBUI_VERSION: '02.forge' ports: - - 9022:9000/tcp + - ${FORGE_PORT:-9022}:9000/tcp stable-diffusion-invoke-ai: <<: *default-service @@ -49,7 +49,7 @@ services: <<: *default-environment WEBUI_VERSION: '03' ports: - - 9003:9000/tcp + - ${INVOKE_AI_PORT:-9003}:9000/tcp stable-diffusion-sd-next: <<: *default-service @@ -59,7 +59,7 @@ services: <<: *default-environment WEBUI_VERSION: '04' ports: - - 9004:9000/tcp + - ${SD_NEXT_PORT:-9004}:9000/tcp stable-diffusion-comfy-ui: <<: *default-service @@ -69,7 +69,7 @@ services: <<: *default-environment WEBUI_VERSION: '05' ports: - - 9005:9000/tcp + - ${COMFY_UI_PORT:-}9005:9000/tcp stable-diffusion-fooocus: <<: *default-service @@ -79,7 +79,7 @@ services: <<: *default-environment WEBUI_VERSION: '06' ports: - - 9006:9000/tcp + - ${FOOOCUS_PORT:-9006}:9000/tcp stable-diffusion-stable-swarm: <<: *default-service @@ -89,7 +89,7 @@ services: <<: *default-environment WEBUI_VERSION: '07' ports: - - 9007:9000/tcp + - ${STABLE_SWARM_PORT:-9007}:9000/tcp stable-diffusion-lama-cleaner: <<: *default-service @@ -99,7 +99,7 @@ services: <<: *default-environment WEBUI_VERSION: '50' ports: - - 9050:9000/tcp + - ${LAMA_CLEANER_PORT:-9050}:9000/tcp stable-diffusion-face-fusion: <<: *default-service @@ -109,7 +109,7 @@ services: <<: *default-environment WEBUI_VERSION: '51' ports: - - 9051:9000/tcp + - ${FACE_FUSION_PORT:-9051}:9000/tcp stable-diffusion-kohya: <<: *default-service @@ -119,4 +119,4 @@ services: <<: *default-environment WEBUI_VERSION: '70' ports: - - 9070:9000/tcp \ No newline at end of file + - ${KOHYA_PORT:-9070}:9000/tcp