Skip to content

Commit eb35828

Browse files
fix(post): Added general docker compose example
1 parent da636c5 commit eb35828

File tree

1 file changed

+259
-1
lines changed

1 file changed

+259
-1
lines changed

_posts/2024-07-08-ai-stack-tutorial.md

Lines changed: 259 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,30 @@ docker compose up -d --build
263263

264264
There are additional steps you'll need to do before starting this stack. Please continue on to the end.
265265

266+
Here are 2 Docker compose files that you can use on your system.
267+
268+
### My Docker Compose Stack
269+
270+
The stack is the one I use in the video as well as at home. If you want to use the general stack without traefik and macvlan, see [the general Docker compose stack](#general-docker-compose-stack)
271+
272+
Before running this, you will need to create the network for Docker to use.
273+
274+
This might already exist if you are using traefik. If so skip this step.
275+
276+
```bash
277+
docker network create traefik
278+
```
279+
280+
This will create the `macvlan` network. Adjust accordingly.
281+
282+
```bash
283+
docker network create -d macvlan \
284+
--subnet=192.168.20.0/24 \
285+
--gateway=192.168.20.1 \
286+
-o parent=eth1 \
287+
iot_macvlan
288+
```
289+
266290
`compose.yaml`
267291

268292
```yaml
@@ -498,6 +522,222 @@ networks:
498522
external: true
499523
```
500524
525+
### General Docker Compose Stack
526+
527+
This Docker compose stack does not use traefik and also exposes the port on the host for each service. If you don't want to expose the port, comment that section out. If you want to use the stack with traefik and macvlan, see the [stack I used in the video](#ai-stack-docker-compose)
528+
529+
Before running this, you will need to create the network for Docker to use.
530+
531+
```bash
532+
docker network create ai-stack
533+
```
534+
535+
```yaml
536+
services:
537+
538+
ollama:
539+
image: ollama/ollama:latest
540+
container_name: ollama
541+
restart: unless-stopped
542+
environment:
543+
- PUID=${PUID:-1000}
544+
- PGID=${PGID:-1000}
545+
- OLLAMA_KEEP_ALIVE=24h
546+
- ENABLE_IMAGE_GENERATION=True
547+
- COMFYUI_BASE_URL=http://stable-diffusion-webui:7860
548+
networks:
549+
- traefik
550+
volumes:
551+
- /etc/localtime:/etc/localtime:ro
552+
- /etc/timezone:/etc/timezone:ro
553+
- ./ollama:/root/.ollama
554+
ports:
555+
- "11434:11434" # Add this line to expose the port
556+
deploy:
557+
resources:
558+
reservations:
559+
devices:
560+
- driver: nvidia
561+
count: 1
562+
capabilities: [gpu]
563+
564+
open-webui:
565+
image: ghcr.io/open-webui/open-webui:latest
566+
container_name: open-webui
567+
restart: unless-stopped
568+
networks:
569+
- traefik
570+
environment:
571+
- PUID=${PUID:-1000}
572+
- PGID=${PGID:-1000}
573+
- 'OLLAMA_BASE_URL=http://ollama:11434'
574+
- ENABLE_RAG_WEB_SEARCH=True
575+
- RAG_WEB_SEARCH_ENGINE=searxng
576+
- RAG_WEB_SEARCH_RESULT_COUNT=3
577+
- RAG_WEB_SEARCH_CONCURRENT_REQUESTS=10
578+
- SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>
579+
volumes:
580+
- /etc/localtime:/etc/localtime:ro
581+
- /etc/timezone:/etc/timezone:ro
582+
- ./open-webui:/app/backend/data
583+
depends_on:
584+
- ollama
585+
extra_hosts:
586+
- host.docker.internal:host-gateway
587+
ports:
588+
- "8080:8080" # Add this line to expose the port
589+
590+
searxng:
591+
image: searxng/searxng:latest
592+
container_name: searxng
593+
networks:
594+
- traefik
595+
environment:
596+
- PUID=${PUID:-1000}
597+
- PGID=${PGID:-1000}
598+
volumes:
599+
- /etc/localtime:/etc/localtime:ro
600+
- /etc/timezone:/etc/timezone:ro
601+
- ./searxng:/etc/searxng
602+
depends_on:
603+
- ollama
604+
- open-webui
605+
restart: unless-stopped
606+
ports:
607+
- "8081:8080" # Add this line to expose the port
608+
609+
stable-diffusion-download:
610+
build: ./stable-diffusion-webui-docker/services/download/
611+
image: comfy-download
612+
environment:
613+
- PUID=${PUID:-1000}
614+
- PGID=${PGID:-1000}
615+
volumes:
616+
- /etc/localtime:/etc/localtime:ro
617+
- /etc/timezone:/etc/timezone:ro
618+
- ./stable-diffusion-webui-docker/data:/data
619+
620+
stable-diffusion-webui:
621+
build: ./stable-diffusion-webui-docker/services/comfy/
622+
image: comfy-ui
623+
environment:
624+
- PUID=${PUID:-1000}
625+
- PGID=${PGID:-1000}
626+
- CLI_ARGS=
627+
volumes:
628+
- /etc/localtime:/etc/localtime:ro
629+
- /etc/timezone:/etc/timezone:ro
630+
- ./stable-diffusion-webui-docker/data:/data
631+
- ./stable-diffusion-webui-docker/output:/output
632+
stop_signal: SIGKILL
633+
tty: true
634+
deploy:
635+
resources:
636+
reservations:
637+
devices:
638+
- driver: nvidia
639+
device_ids: ['0']
640+
capabilities: [compute, utility]
641+
restart: unless-stopped
642+
networks:
643+
- traefik
644+
ports:
645+
- "7860:7860" # Add this line to expose the port
646+
647+
mongo:
648+
image: mongo
649+
env_file:
650+
- .env
651+
networks:
652+
- traefik
653+
restart: unless-stopped
654+
volumes:
655+
- /etc/localtime:/etc/localtime:ro
656+
- /etc/timezone:/etc/timezone:ro
657+
- ./whisper/db_data:/data/db
658+
- ./whisper/db_data/logs/:/var/log/mongodb/
659+
environment:
660+
- PUID=${PUID:-1000}
661+
- PGID=${PGID:-1000}
662+
- MONGO_INITDB_ROOT_USERNAME=${DB_USER:-whishper}
663+
- MONGO_INITDB_ROOT_PASSWORD=${DB_PASS:-whishper}
664+
command: ['--logpath', '/var/log/mongodb/mongod.log']
665+
ports:
666+
- "27017:27017" # Add this line to expose the port
667+
668+
translate:
669+
container_name: whisper-libretranslate
670+
image: libretranslate/libretranslate:latest-cuda
671+
env_file:
672+
- .env
673+
networks:
674+
- traefik
675+
restart: unless-stopped
676+
volumes:
677+
- /etc/localtime:/etc/localtime:ro
678+
- /etc/timezone:/etc/timezone:ro
679+
- ./whisper/libretranslate/data:/home/libretranslate/.local/share
680+
- ./whisper/libretranslate/cache:/home/libretranslate/.local/cache
681+
user: root
682+
tty: true
683+
environment:
684+
- PUID=${PUID:-1000}
685+
- PGID=${PGID:-1000}
686+
- LT_DISABLE_WEB_UI=True
687+
- LT_LOAD_ONLY=${LT_LOAD_ONLY:-en,fr,es}
688+
- LT_UPDATE_MODELS=True
689+
deploy:
690+
resources:
691+
reservations:
692+
devices:
693+
- driver: nvidia
694+
count: all
695+
capabilities: [gpu]
696+
ports:
697+
- "5000:5000" # Add this line to expose the port
698+
699+
whisper:
700+
container_name: whisper
701+
pull_policy: always
702+
image: pluja/whishper:latest-gpu
703+
env_file:
704+
- .env
705+
networks:
706+
- traefik
707+
volumes:
708+
- /etc/localtime:/etc/localtime:ro
709+
- /etc/timezone:/etc/timezone:ro
710+
- ./whisper/uploads:/app/uploads
711+
- ./whisper/logs:/var/log/whishper
712+
- ./whisper/models:/app/models
713+
restart: unless-stopped
714+
depends_on:
715+
- mongo
716+
- translate
717+
environment:
718+
- PUID=${PUID:-1000}
719+
- PGID=${PGID:-1000}
720+
- PUBLIC_INTERNAL_API_HOST=${WHISHPER_HOST}
721+
- PUBLIC_TRANSLATION_API_HOST=${WHISHPER_HOST}
722+
- PUBLIC_API_HOST=${WHISHPER_HOST:-}
723+
- PUBLIC_WHISHPER_PROFILE=gpu
724+
- WHISPER_MODELS_DIR=/app/models
725+
- UPLOAD_DIR=/app/uploads
726+
deploy:
727+
resources:
728+
reservations:
729+
devices:
730+
- driver: nvidia
731+
count: all
732+
capabilities: [gpu]
733+
ports:
734+
- "8000:80" # Add this line to expose the port
735+
736+
networks:
737+
ai-stack:
738+
external: true
739+
```
740+
501741
## Changes for ComfyUI
502742
503743
Before starting the stack, in the room `ai-stack` folder, you'll want to clone the repo (or just copy the necessary files).
@@ -615,14 +855,32 @@ You'll want to be sure the checksum matches the checksum from the source ([Huggi
615855

616856
Please see [folder structure](#folder-structure) above
617857

858+
Before running this, you will need to create the network for Docker to use.
859+
860+
This might already exist if you are using traefik. If so skip this step.
861+
862+
```bash
863+
docker network create traefik
864+
```
865+
866+
This will create the `macvlan` network. Adjust accordingly.
867+
868+
```bash
869+
docker network create -d macvlan \
870+
--subnet=192.168.20.0/24 \
871+
--gateway=192.168.20.1 \
872+
-o parent=eth1 \
873+
iot_macvlan
874+
```
875+
618876
```yaml
619877
---
620878
services:
621879
homeassistant:
622880
container_name: homeassistant
623881
networks:
624882
iot_macvlan:
625-
ipv4_address: 192.168.20.202 #optional, I am using mac vlan, if you don't want to, remove iot_macvlan
883+
ipv4_address: 192.168.20.202 #optional, I am using mac vlan, if you don't want to, remove iot_macvlan and don't create the network above
626884
traefik:
627885
image: ghcr.io/home-assistant/home-assistant:stable
628886
depends_on:

0 commit comments

Comments
 (0)