From 1eaff2dff067e8080aa1c8edfb2fb8e80b03918a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 13 Nov 2024 16:22:57 +0100 Subject: [PATCH] Restructure service overrides --- ...er-compose.yml => docker-compose.base.yml} | 3 --- .../docker/services/anki-sync/main.fish | 2 +- .../docker/services/docker-compose.yml | 4 ++++ .../services/drone/docker-compose.secrets.yml | 0 .../drone/docker-compose.templates.yml | 9 --------- .../Software/docker/services/drone/main.fish | 20 +------------------ ...er-compose.yml => docker-compose.base.yml} | 6 ------ .../docker/services/forgejo/main.fish | 8 ++++---- ...er-compose.yml => docker-compose.base.yml} | 18 ----------------- .../docker/services/jellyfin/main.fish | 8 ++++---- .../Software/docker/services/service.fish | 5 +++-- ...er-compose.yml => docker-compose.base.yml} | 6 ------ .../docker/services/vaultwarden/main.fish | 2 +- 13 files changed, 18 insertions(+), 73 deletions(-) rename scripts/Common/Software/docker/services/anki-sync/{docker-compose.yml => docker-compose.base.yml} (64%) create mode 100644 scripts/Common/Software/docker/services/docker-compose.yml delete mode 100644 scripts/Common/Software/docker/services/drone/docker-compose.secrets.yml rename scripts/Common/Software/docker/services/forgejo/{docker-compose.yml => docker-compose.base.yml} (91%) rename scripts/Common/Software/docker/services/jellyfin/{docker-compose.yml => docker-compose.base.yml} (85%) rename scripts/Common/Software/docker/services/vaultwarden/{docker-compose.yml => docker-compose.base.yml} (82%) diff --git a/scripts/Common/Software/docker/services/anki-sync/docker-compose.yml b/scripts/Common/Software/docker/services/anki-sync/docker-compose.base.yml similarity index 64% rename from scripts/Common/Software/docker/services/anki-sync/docker-compose.yml rename to scripts/Common/Software/docker/services/anki-sync/docker-compose.base.yml index a5c42254..99cd203a 100644 --- a/scripts/Common/Software/docker/services/anki-sync/docker-compose.yml +++ b/scripts/Common/Software/docker/services/anki-sync/docker-compose.base.yml @@ -2,8 +2,5 @@ services: anki: image: yangchuansheng/anki-sync-server restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: anki volumes: - ./data:/ankisyncdir diff --git a/scripts/Common/Software/docker/services/anki-sync/main.fish b/scripts/Common/Software/docker/services/anki-sync/main.fish index b68be125..ad9b82bd 100644 --- a/scripts/Common/Software/docker/services/anki-sync/main.fish +++ b/scripts/Common/Software/docker/services/anki-sync/main.fish @@ -10,7 +10,7 @@ begin set -l userKey ".services.anki.environment.SYNC_USER1" set -l user (yq --raw-output "$userKey" "$source" | sed "s/:.*\$/:$pw/") initializeServiceInstallation $argv - sudo cp "$dir/docker-compose.yml" (getServiceRoot $argv) + sudo cp "$dir/docker-compose.base.yml" (getServiceRoot $argv) USER=$user yq "$userKey = env.USER" "$source" | \ sudo tee (getServiceSecretsConfig $argv) >/dev/null diff --git a/scripts/Common/Software/docker/services/docker-compose.yml b/scripts/Common/Software/docker/services/docker-compose.yml new file mode 100644 index 00000000..2e1ecd19 --- /dev/null +++ b/scripts/Common/Software/docker/services/docker-compose.yml @@ -0,0 +1,4 @@ +include: + - path: + - docker-compose.base.yml + - docker-compose.secrets.yml diff --git a/scripts/Common/Software/docker/services/drone/docker-compose.secrets.yml b/scripts/Common/Software/docker/services/drone/docker-compose.secrets.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/Common/Software/docker/services/drone/docker-compose.templates.yml b/scripts/Common/Software/docker/services/drone/docker-compose.templates.yml index a671b0fe..742f3a3c 100644 --- a/scripts/Common/Software/docker/services/drone/docker-compose.templates.yml +++ b/scripts/Common/Software/docker/services/drone/docker-compose.templates.yml @@ -3,18 +3,12 @@ services: build: context: . dockerfile: ci.Dockerfile - extends: - file: docker-compose.secrets.yml - service: template restart: unless-stopped env_file: - server.common.env docker-template: image: drone/drone-runner-docker restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: template depends_on: [] env_file: - runner.common.env @@ -25,9 +19,6 @@ services: ssh-template: image: drone/drone-runner-ssh restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: template depends_on: [] env_file: - runner.common.env diff --git a/scripts/Common/Software/docker/services/drone/main.fish b/scripts/Common/Software/docker/services/drone/main.fish index 32d042dc..50e49933 100644 --- a/scripts/Common/Software/docker/services/drone/main.fish +++ b/scripts/Common/Software/docker/services/drone/main.fish @@ -10,7 +10,7 @@ begin function installSW -V dir -V environments -V source set -l root (getServiceRoot $argv) - set -l config "$root/docker-compose.yml" + set -l config "$root/docker-compose.base.yml" set -l secrets (getServiceSecretsConfig $argv) set -l ciTemplate (yq (getServiceKey ci-template) "$source") set -l dockerTemplate (yq (getServiceKey docker-template) "$source") @@ -91,24 +91,6 @@ begin end end - set -l services (yq --raw-output0 ".services | keys[]" "$config" | string split0) - - for service in $services - set -l file (mktemp) - set -l key "$(getServiceKey "$service").extends" - - cat "$config" | if string match "*-ci" "$service" >/dev/null - SERVICE="$service" yq "$key.service |= env.SERVICE" "$config" - else - yq "del($key)" "$config" - end | \ - yq -y "." | \ - tee "$file" >/dev/null - - sudo cp "$file" "$config" - rm "$file" - end - installDockerService $argv end diff --git a/scripts/Common/Software/docker/services/forgejo/docker-compose.yml b/scripts/Common/Software/docker/services/forgejo/docker-compose.base.yml similarity index 91% rename from scripts/Common/Software/docker/services/forgejo/docker-compose.yml rename to scripts/Common/Software/docker/services/forgejo/docker-compose.base.yml index ea48bd4b..618277d9 100644 --- a/scripts/Common/Software/docker/services/forgejo/docker-compose.yml +++ b/scripts/Common/Software/docker/services/forgejo/docker-compose.base.yml @@ -2,9 +2,6 @@ services: forgejo: image: codeberg.org/forgejo/forgejo:7 restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: forgejo depends_on: - db environment: @@ -31,9 +28,6 @@ services: db: image: mariadb restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: db environment: MARIADB_RANDOM_ROOT_PASSWORD: "yes" MARIADB_AUTO_UPGRADE: "yes" diff --git a/scripts/Common/Software/docker/services/forgejo/main.fish b/scripts/Common/Software/docker/services/forgejo/main.fish index 579e7bda..297bfebc 100644 --- a/scripts/Common/Software/docker/services/forgejo/main.fish +++ b/scripts/Common/Software/docker/services/forgejo/main.fish @@ -18,7 +18,7 @@ begin set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32") set -l port (getRandomPort) initializeServiceInstallation $argv - sudo cp "$dir/docker-compose.yml" "$root" + sudo cp "$dir/docker-compose.base.yml" "$root" installDockerService $argv set port (yq (getSSHPortKey) "$source" --raw-output | mutatePort "$port") @@ -47,7 +47,7 @@ begin set -l root (getServiceRoot $argv) set -l dir "$root/data" set -l bin "/usr/local/bin/forgejo" - set -l config "$root/docker-compose.yml" + set -l config "$root/docker-compose.base.yml" set -l secrets (getServiceSecretsConfig $argv) set -l envKey "$(getServiceKey "$service").environment" configureDockerService $argv @@ -92,8 +92,8 @@ begin printf "%s\0" "$_flag_name" / end - function getBackupArgs - printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv) + function getBackupArgs -V root + printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" --exclude "docker-compose.base.yml" (getServiceRoot $argv) end runInstaller --force $argv diff --git a/scripts/Common/Software/docker/services/jellyfin/docker-compose.yml b/scripts/Common/Software/docker/services/jellyfin/docker-compose.base.yml similarity index 85% rename from scripts/Common/Software/docker/services/jellyfin/docker-compose.yml rename to scripts/Common/Software/docker/services/jellyfin/docker-compose.base.yml index 13668b20..fdb69629 100644 --- a/scripts/Common/Software/docker/services/jellyfin/docker-compose.yml +++ b/scripts/Common/Software/docker/services/jellyfin/docker-compose.base.yml @@ -2,9 +2,6 @@ services: jellyfin: image: jellyfin/jellyfin restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: jellyfin user: 1337:1337 hostname: Jellyfin environment: {} @@ -15,9 +12,6 @@ services: radarr: image: linuxserver/radarr restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: radarr environment: PUID: 1337 PGID: 1337 @@ -29,9 +23,6 @@ services: sonarr: image: linuxserver/sonarr restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: sonarr environment: PUID: 1337 PGID: 1337 @@ -43,9 +34,6 @@ services: lidarr: image: linuxserver/lidarr restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: lidarr environment: PUID: 1337 PGID: 1337 @@ -57,9 +45,6 @@ services: prowlarr: image: linuxserver/prowlarr restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: prowlarr environment: PUID: 1337 PGID: 1337 @@ -85,9 +70,6 @@ services: flood: image: jesec/flood restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: flood user: 1337:1337 command: --baseuri /flood --rundir /flood diff --git a/scripts/Common/Software/docker/services/jellyfin/main.fish b/scripts/Common/Software/docker/services/jellyfin/main.fish index 8231aef8..18ee2bbc 100644 --- a/scripts/Common/Software/docker/services/jellyfin/main.fish +++ b/scripts/Common/Software/docker/services/jellyfin/main.fish @@ -16,7 +16,7 @@ begin set -l port (getRandomPort) set -l servarrKeys initializeServiceInstallation $argv - sudo cp "$dir/docker-compose.yml" "$root" + sudo cp "$dir/docker-compose.base.yml" "$root" sudo cp "$dir/.dockerignore" "$root" sudo cp "$dir/pvpn-cli.py" "$root" sudo cp "$dir/rtorrent.Dockerfile" "$root" @@ -32,7 +32,7 @@ begin set -l file (mktemp) set -l root (getServiceRoot $argv) set -l bin "/usr/local/bin/forgejo" - set -l config "$root/docker-compose.yml" + set -l config "$root/docker-compose.base.yml" set -l secrets (getServiceSecretsConfig $argv) set -l envKey "$(getServiceKey "$service").environment" configureDockerService $argv @@ -138,8 +138,8 @@ begin end end - function getBackupArgs - printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv) + function getBackupArgs -V root + printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" --exclude "docker-compose.base.yml" (getServiceRoot $argv) end runInstaller --force $argv diff --git a/scripts/Common/Software/docker/services/service.fish b/scripts/Common/Software/docker/services/service.fish index fe5ca5a7..250063a3 100644 --- a/scripts/Common/Software/docker/services/service.fish +++ b/scripts/Common/Software/docker/services/service.fish @@ -111,10 +111,11 @@ begin function getExtraLocationSettings -a domain service location end - function initializeServiceInstallation -V nginxRoot + function initializeServiceInstallation -V dir -V nginxRoot sudo mkdir -p (getServiceRoot $argv) sudo mkdir -p "$nginxRoot" sudo mkdir -p (dirname (getServiceSecretsConfig $argv)) + sudo cp "$dir/docker-compose.yml" "$root" end function installDockerService -V dir -V nginxRoot @@ -171,6 +172,6 @@ begin end function getBackupArgs - printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv) + printf "%s\n" --hidden --no-ignore . --exclude "docker-compose"{,.base}".yml" (getServiceRoot $argv) end end diff --git a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.yml b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml similarity index 82% rename from scripts/Common/Software/docker/services/vaultwarden/docker-compose.yml rename to scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml index 10a3aa05..157dc522 100644 --- a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.yml +++ b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml @@ -2,9 +2,6 @@ services: vaultwarden: image: vaultwarden/server restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: vaultwarden volumes: - ./data:/data - /etc/localtime:/etc/localtime:ro @@ -20,9 +17,6 @@ services: db: image: mariadb restart: unless-stopped - extends: - file: docker-compose.secrets.yml - service: db volumes: - ./db:/var/lib/mysql - /etc/localtime:/etc/localtime:ro diff --git a/scripts/Common/Software/docker/services/vaultwarden/main.fish b/scripts/Common/Software/docker/services/vaultwarden/main.fish index fd071213..f5174438 100644 --- a/scripts/Common/Software/docker/services/vaultwarden/main.fish +++ b/scripts/Common/Software/docker/services/vaultwarden/main.fish @@ -6,7 +6,7 @@ begin source "$dir/../service.fish" function installSW -V dir -V domain -V source - set -l file "$dir/docker-compose.yml" + set -l file "$dir/docker-compose.base.yml" set -l pw (nix-shell -p keepassxc --run "keepassxc-cli generate --length 32") set -l envKey ".services.vaultwarden.environment" set -l dbKey "$envKey.DATABASE_URL"