diff --git a/scripts/Common/Software/docker/services/ryot/docker-compose.base.yml b/scripts/Common/Software/docker/services/ryot/docker-compose.base.yml new file mode 100644 index 00000000..82ca2112 --- /dev/null +++ b/scripts/Common/Software/docker/services/ryot/docker-compose.base.yml @@ -0,0 +1,11 @@ +services: + ryot: + image: ghcr.io/ignisda/ryot:latest + restart: unless-stopped + volumes: + - ./data:/data + db: + image: postgres + restart: unless-stopped + volumes: + - ./database:/var/lib/postgresql/data diff --git a/scripts/Common/Software/docker/services/ryot/docker-compose.secrets.yml b/scripts/Common/Software/docker/services/ryot/docker-compose.secrets.yml new file mode 100644 index 00000000..9a170ebd --- /dev/null +++ b/scripts/Common/Software/docker/services/ryot/docker-compose.secrets.yml @@ -0,0 +1,11 @@ +services: + ryot: + environment: + DATABASE_URL: postgres://ryot:pw@db/Ryot + ports: + - 127.0.0.1:1337:8000 + db: + environment: + POSTGRES_DB: Ryot + POSTGRES_USER: ryot + POSTGRES_PASSWORD: pw diff --git a/scripts/Common/Software/docker/services/ryot/main.fish b/scripts/Common/Software/docker/services/ryot/main.fish new file mode 100644 index 00000000..72a34b2b --- /dev/null +++ b/scripts/Common/Software/docker/services/ryot/main.fish @@ -0,0 +1,44 @@ +#!/bin/env fish +begin + set -l dir (status dirname) + set -l domain "tracker" "" + set -l service "ryot" + set -l source "$dir/docker-compose.secrets.yml" + source "$dir/../service.fish" + + function installSW -V dir -V domain -V service -V source + set -l domain (getServiceDomain $domain) + set -l root (getServiceRoot $argv) + 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.$service.environment" + set -l dbKey "$envKey.DATABASE_URL" + set -l dbUrl (yq --raw-output "$dbKey" "$source" | sed "s/^\(.*:\/\/.*:\).*\(@.*\/.*\)\$/\1$pw\2/") + initializeServiceInstallation $argv + sudo cp "$file" "$root" + + URL=$dbUrl yq "$dbKey = env.URL" "$source" | \ + PW=$pw yq ".services.db.environment.POSTGRES_PASSWORD = env.PW" | \ + sudo tee (getServiceSecretsConfig $argv) >/dev/null + + installDockerService $argv + end + + function configureSW -V dir + configureDockerService $argv + end + + function getServiceServers -V domain + printf "%s\0" $domain + end + + function getServiceLocations -V service + printf "%s\0" $service / + end + + function getBackupArgs + printf "%s\n" --hidden --no-ignore . --exclude "docker-compose.yml" (getServiceRoot $argv) + end + + runInstaller --force $argv +end