From 225d205910614b4e97b2d4cb7c4e42d5bf788f43 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 27 Nov 2024 03:41:26 +0100 Subject: [PATCH] Store domain names in overrides --- .../docker/services/nextcloud/main.fish | 26 ++++++------------- .../vaultwarden/docker-compose.base.yml | 1 - .../vaultwarden/docker-compose.overrides.yml | 2 ++ .../docker/services/vaultwarden/main.fish | 9 +++---- .../services/wekan/docker-compose.base.yml | 1 - .../wekan/docker-compose.overrides.yml | 2 ++ .../Software/docker/services/wekan/main.fish | 9 ++++--- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/scripts/Common/Software/docker/services/nextcloud/main.fish b/scripts/Common/Software/docker/services/nextcloud/main.fish index 9b50d9dc..82299a13 100644 --- a/scripts/Common/Software/docker/services/nextcloud/main.fish +++ b/scripts/Common/Software/docker/services/nextcloud/main.fish @@ -31,8 +31,6 @@ begin set -l source "$dir/docker-compose.core.yml" set -l core "$root/$(basename "$source")" set -l domain (getServiceDomain $domain) - set -l base "$root/docker-compose.base.yml" - set -l baseSource "$dir/$(basename "$base")" set -l overrides (getServiceOverrides $argv) set -l overridesSource "$dir/$(basename "$overrides")" set -l turnKey "$(getServiceKey "$turn")" @@ -45,7 +43,7 @@ begin set -l nextcloudPW ($genPW 64) initializeServiceInstallation $argv - sudo cp -r "$dir"/{cache.Dockerfile,cloud.Dockerfile,.dockerignore,fpm,nginx,php.ini} "$root" + sudo cp -r "$dir"/{cache.Dockerfile,cloud.Dockerfile,docker-compose.{base,core}.yml,.dockerignore,fpm,nginx,php.ini} "$root" begin printf "%s\n" \ @@ -59,29 +57,21 @@ begin begin printf "%s\n" \ "NEXTCLOUD_ADMIN_USER=admin" \ - "NEXTCLOUD_ADMIN_PASSWORD=$nextcloudPW" + "NEXTCLOUD_ADMIN_PASSWORD=$nextcloudPW" \ + "NEXTCLOUD_TRUSTED_DOMAINS=$domain" \ + "OVERWRITEPROTOCOL=https" \ + "OVERWRITEHOST=$domain" \ + "OVERWRITECLIURL=https://$domain" end | sudo tee "$root/nextcloud.env" >/dev/null PROTO="https" DOMAIN="$domain" begin - set -l envKey "$(getServiceKey nextcloud).environment" - - yq "$envKey.NEXTCLOUD_TRUSTED_DOMAINS = env(DOMAIN)" "$source" | \ - yq "$envKey.OVERWRITEPROTOCOL = env(PROTO)" | \ - yq "$envKey.OVERWRITEHOST = env(DOMAIN)" | \ - URL="$PROTO://$DOMAIN" yq "$envKey.OVERWRITECLIURL = env(URL)" | \ - sudo tee "$core" >/dev/null - - DOMAIN=(getServiceDomain $officeDomain) yq "$officeEnv.server_name = env(DOMAIN)" "$baseSource" | \ - URL="https://$(string escape --style regex "$DOMAIN"):443" yq "$officeEnv.aliasgroup1 = env(URL)" | \ - sudo tee "$base" >/dev/null - end - - begin set -l key "$turnKey.command" PW="--static-auth-secret=$turnPW" \ DOMAIN="--realm=$domain" \ yq "$key |= . + [env(PW), env(DOMAIN)]" "$overridesSource" | \ + DOMAIN=(getServiceDomain $officeDomain) yq "$officeEnv.server_name = env(DOMAIN)" | \ + URL="https://$(string escape --style regex "$DOMAIN"):443" yq "$officeEnv.aliasgroup1 = env(URL)" | \ sudo tee "$overrides" >/dev/null end diff --git a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml index 2e99cdd4..fda1d25b 100644 --- a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml +++ b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.base.yml @@ -7,7 +7,6 @@ services: - ./data/vault:/data environment: SMTP_HOST: bridge - SMTP_FROM: null SMTP_FROM_VALUE: vaultwarden SMTP_PORT: 25 SMTP_ACCEPT_INVALID_CERTS: "true" diff --git a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.overrides.yml b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.overrides.yml index a53cc9e6..2b5129e2 100644 --- a/scripts/Common/Software/docker/services/vaultwarden/docker-compose.overrides.yml +++ b/scripts/Common/Software/docker/services/vaultwarden/docker-compose.overrides.yml @@ -1,6 +1,8 @@ services: vaultwarden: environment: + DOMAIN: null + SMTP_FROM: null DATABASE_URL: mysql://vaultwarden:pw@db/vault ports: - 127.0.0.1:1337:80 diff --git a/scripts/Common/Software/docker/services/vaultwarden/main.fish b/scripts/Common/Software/docker/services/vaultwarden/main.fish index 0195b32e..50344ba2 100644 --- a/scripts/Common/Software/docker/services/vaultwarden/main.fish +++ b/scripts/Common/Software/docker/services/vaultwarden/main.fish @@ -12,12 +12,11 @@ begin set -l dbKey "$envKey.DATABASE_URL" set -l dbUrl (yq "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/") initializeServiceInstallation $argv + cp "$dir/docker-compose.base.yml" (getServiceRoot $argv) - URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env(URL)" "$file" | \ - ADDRESS="noreply@$(getMachineFQDN)" yq "$envKey.SMTP_FROM = env(ADDRESS)" | \ - sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null - - URL=$dbUrl yq "$dbKey = env(URL)" "$source" | \ + URL="https://$domain.$(getMachineFQDN)" yq "$envKey.DOMAIN = env(URL)" "$source" | \ + ADDRESS="no-reply@$(getMachineFQDN)" yq "$envKey.SMTP_FROM = env(ADDRESS)" | \ + URL=$dbUrl yq "$dbKey = env(URL)" | \ PW=$pw yq ".services.db.environment.MARIADB_PASSWORD = env(PW)" | \ sudo tee (getServiceOverrides $argv) >/dev/null diff --git a/scripts/Common/Software/docker/services/wekan/docker-compose.base.yml b/scripts/Common/Software/docker/services/wekan/docker-compose.base.yml index 9f645a33..2ac005b3 100644 --- a/scripts/Common/Software/docker/services/wekan/docker-compose.base.yml +++ b/scripts/Common/Software/docker/services/wekan/docker-compose.base.yml @@ -7,7 +7,6 @@ services: user: 1337:1337 environment: WRITABLE_PATH: /data - ROOT_URL: https://example.com MONGO_URL: mongodb://db:27017/wekan MONGO_OPLOG_URL: WITH_API: "true" diff --git a/scripts/Common/Software/docker/services/wekan/docker-compose.overrides.yml b/scripts/Common/Software/docker/services/wekan/docker-compose.overrides.yml index d9824c88..2329051e 100644 --- a/scripts/Common/Software/docker/services/wekan/docker-compose.overrides.yml +++ b/scripts/Common/Software/docker/services/wekan/docker-compose.overrides.yml @@ -1,4 +1,6 @@ services: wekan: + environment: + ROOT_URL: https://example.com ports: - 127.0.0.1:1337:8080 diff --git a/scripts/Common/Software/docker/services/wekan/main.fish b/scripts/Common/Software/docker/services/wekan/main.fish index d8f8d114..10ffcfc0 100755 --- a/scripts/Common/Software/docker/services/wekan/main.fish +++ b/scripts/Common/Software/docker/services/wekan/main.fish @@ -7,13 +7,14 @@ begin function installSW -V dir -V service -V domain set -l domain (getServiceDomain $domain) - set -l file "$dir/docker-compose.base.yml" + set -l overrides (getServiceOverrides $argv) initializeServiceInstallation $argv - URL="https://$domain" yq "$(getServiceKey "$service").environment.DOMAIN = env(URL)" "$file" | \ - sudo tee "$(getServiceRoot $argv)/$(basename "$file")" >/dev/null + sudo cp "$dir/docker-compose.base.yml" (getServiceRoot $argv) + + URL="https://$domain" yq "$(getServiceKey "$service").environment.ROOT_URL = env(URL)" "$dir/$(basename "$overrides")" | \ + sudo tee "$overrides" >/dev/null - sudo cp "$dir/docker-compose.overrides.yml" (getServiceRoot $argv) installDockerService $argv end