Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose changes #6043

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,6 @@ installer/install.sh
installer/update.bat
installer/update.sh
installer/InvokeAI-Installer/

# Docker
docker/compose.override.yaml
9 changes: 9 additions & 0 deletions docker/compose.override.yaml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
invokeai-cuda:
restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.invokeai-cuda.rule=Host(`invokeai.example.com`)
- traefik.http.routers.invokeai-cuda.entrypoints=websecure
- traefik.http.middlewares.invokeai-cuda-ipwhitelist.ipwhitelist.sourcerange=0.0.0.0/0
- traefik.http.routers.invokeai-cuda.middlewares=invokeai-cuda-ipwhitelist
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ x-invokeai: &invokeai
- ${HF_HOME:-~/.cache/huggingface}:${HF_HOME:-/invokeai/.cache/huggingface}
tty: true
stdin_open: true

labels: []

services:
invokeai-nvidia:
invokeai-cuda:
<<: *invokeai
deploy:
resources:
Expand Down
11 changes: 9 additions & 2 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ run() {
local profile=""

touch .env
build_args=$(awk '$1 ~ /=[^$]/ && $0 !~ /^#/ {print "--build-arg " $0 " "}' .env) &&
while IFS='=' read -r key value; do
if [[ ! $key =~ ^# && ! -z $value ]]; then
build_args+=" --build-arg $key=$value"
export "$key=$value"
fi
done < .env
profile="$(awk -F '=' '/GPU_DRIVER/ {print $2}' .env)"

[[ -z "$profile" ]] && profile="nvidia"
Expand All @@ -25,7 +30,9 @@ run() {
unset build_args

printf "%s\n" "starting service $service_name"
docker compose --profile "$profile" up -d "$service_name"
# `touch compose.override.yaml` in case user doesn't use it (i.e., doesn't have it)
touch compose.override.yaml
docker compose --profile "$profile" -f docker-compose.yml -f compose.override.yaml up -d "$service_name"
docker compose logs -f
}

Expand Down