From 682dcaad17cc7557f0aebac2a20e956c678625f5 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Thu, 12 Nov 2026 16:59:30 +0100 Subject: [PATCH] fix(install): resolve optional service secrets from install root (#319) --- install/install-server.ps1 | 2 +- install/install-server.sh | 3 ++- scripts/ci/test_ci.py | 8 ++++++++ skills/optional-server-services/SKILL.md | 6 +++--- skills/optional-server-services/acceptance.sh | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/install/install-server.ps1 b/install/install-server.ps1 index 0fb2249..b38b64e 100644 --- a/install/install-server.ps1 +++ b/install/install-server.ps1 @@ -379,7 +379,7 @@ foreach ($service in $selected) { } } if ($startCore -and (Read-YesNo "Démarrer le service optionnel $service ?" 'o')) { - Invoke-DockerCompose @('--project-name', "heimdall-$service", '--env-file', $envPath, + Invoke-DockerCompose @('--project-directory', $destination, '--project-name', "heimdall-$service", '--env-file', $envPath, '-f', (Join-Path $optionalDirectory "docker-compose.$service.yml"), 'up', '-d') } else { Write-Host "Service $service préparé dans $optionalDirectory." diff --git a/install/install-server.sh b/install/install-server.sh index 8dc09a9..1bfe56a 100755 --- a/install/install-server.sh +++ b/install/install-server.sh @@ -318,7 +318,8 @@ for service in "${selected[@]}"; do ;; esac if [[ "$start_core" == yes ]] && [[ "$(ask "Démarrer le service optionnel ${service} ?" 'o')" =~ ^([oO]|[oO][uU][iI]|[yY]|[yY][eE][sS])$ ]]; then - docker compose --project-name "heimdall-${service}" --env-file "$destination/.env" \ + docker compose --project-directory "$destination" --project-name "heimdall-${service}" \ + --env-file "$destination/.env" \ -f "$destination/optional/docker-compose.${service}.yml" up -d else say "Service ${service} préparé dans $destination/optional/." diff --git a/scripts/ci/test_ci.py b/scripts/ci/test_ci.py index 319e0d3..1074d57 100644 --- a/scripts/ci/test_ci.py +++ b/scripts/ci/test_ci.py @@ -73,6 +73,14 @@ class PublicationWorkflowTests(unittest.TestCase): self.assertNotIn('secrets.GITEA_TOKEN', workflow.split(' publish:\n', 1)[0]) class PowerShellInstallerTests(unittest.TestCase): + def test_optional_compose_commands_resolve_paths_from_install_root(self): + linux_installer = (REPO_ROOT/'install/install-server.sh').read_text() + windows_installer = (REPO_ROOT/'install/install-server.ps1').read_text() + self.assertIn('docker compose --project-directory "$destination" --project-name', + linux_installer) + self.assertIn("Invoke-DockerCompose @('--project-directory', $destination, '--project-name',", + windows_installer) + @unittest.skipUnless(shutil.which('pwsh'), 'PowerShell is not installed') def test_server_installer_has_valid_powershell_syntax(self): parser = "$tokens=$null; $errors=$null; [void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path 'install/install-server.ps1'), [ref]$tokens, [ref]$errors); if ($errors.Count) { $errors | ForEach-Object { Write-Error $_.Message }; exit 1 }" diff --git a/skills/optional-server-services/SKILL.md b/skills/optional-server-services/SKILL.md index 14b8a04..e3da54b 100644 --- a/skills/optional-server-services/SKILL.md +++ b/skills/optional-server-services/SKILL.md @@ -5,13 +5,13 @@ description: Keep installer-managed RustFS and coturn Compose services aligned w # Installer-managed optional services -The Linux and Windows server installers run optional Compose files with the installation root as the current directory. They save service secrets in `optional/secrets/` and pass the root `.env` for interpolation. Therefore, Compose secret `file:` entries must use `./optional/secrets/`, not `./secrets/` or paths relative to `optional/`. +The Linux and Windows server installers save service secrets in `/optional/secrets/` and pass the root `.env` for interpolation. Compose resolves relative file paths from the project directory, which otherwise defaults to the directory containing the first `-f` file. Because optional Compose files are stored under `optional/`, both installers must pass `--project-directory ` when starting them. Compose secret `file:` entries then use `./optional/secrets/`, not `./secrets/` or paths relative to `optional/`. ## RustFS - Keep `rustfs_access_key` and `rustfs_secret_key` file paths aligned with the generated files from both installers. - Installers create these bind-mounted secret files as owner-only (`0600`), which the official RustFS process (`10001:10001`) cannot read directly. Keep a short root initializer, copy the files into the service's private tmpfs, `chown` the copies to UID/GID 10001, then drop to the `rustfs` account before executing the upstream entrypoint. Keep the root filesystem read-only and provide tmpfs only for runtime paths that RustFS writes (`/logs`, `/tmp`, and its secret copies). -- Verify Compose config from the install-root working directory and ensure Docker secrets are sourced from those files. +- Verify the actual optional-service invocation includes `--project-directory ` and Compose resolves each Docker secret file to the exact file created under `/optional/secrets/`. A successful `config` without checking normalized source paths is insufficient because Compose can accept an unintended path that happens to exist. - Keep the named data volume and shared `heimdall-net` behavior intact. ## coturn @@ -26,4 +26,4 @@ The Linux and Windows server installers run optional Compose files with the inst ## Acceptance -Run `skills/optional-server-services/acceptance.sh`. It creates a uniquely named disposable Compose project, generated owner-only secrets, an isolated install root, unique listener and relay ports, then validates Compose using that root. It verifies RustFS `/health`, signs a real S3 bucket-creation request with the generated keys, and runs `turnutils_uclient` inside the Compose network with TURN REST credentials. This proves local container-network allocation only; it does not prove external firewall/NAT reachability. The trap tears down only that project and verifies its containers, volumes, and networks are absent. The recipe builds no local images and retains upstream images. +Run `skills/optional-server-services/acceptance.sh`. It creates a uniquely named disposable Compose project, generated owner-only secrets, an isolated install root, unique listener and relay ports, then validates Compose using the same explicit `--project-directory ` used by the installers. It asserts the normalized RustFS and coturn secret source paths exactly match the generated files before starting containers. It verifies RustFS `/health`, signs a real S3 bucket-creation request with the generated keys, and runs `turnutils_uclient` inside the Compose network with TURN REST credentials. This proves local container-network allocation only; it does not prove external firewall/NAT reachability. The trap tears down only that project and verifies its containers, volumes, and networks are absent. The recipe builds no local images and retains upstream images. diff --git a/skills/optional-server-services/acceptance.sh b/skills/optional-server-services/acceptance.sh index bf6a1ba..e6eff2a 100755 --- a/skills/optional-server-services/acceptance.sh +++ b/skills/optional-server-services/acceptance.sh @@ -155,6 +155,20 @@ EOF printf 'Disposable project: %s\nLocal images built: none\n' "$project" compose config --quiet +compose config --format json | INSTALL_ROOT="$install_root" python3 -c ' +import json, os, sys +config = json.load(sys.stdin) +root = os.environ["INSTALL_ROOT"] +expected = { + "rustfs_access_key": os.path.join(root, "optional/secrets/rustfs_access_key"), + "rustfs_secret_key": os.path.join(root, "optional/secrets/rustfs_secret_key"), + "coturn_secret": os.path.join(root, "optional/secrets/coturn_secret"), +} +actual = {name: config["secrets"][name]["file"] for name in expected} +if actual != expected: + raise SystemExit("Compose secret bind mounts do not resolve under the installer root") +print("Verified RustFS and coturn secret bind mounts resolve under the installer root.") +' compose up -d rustfs coturn base_url="http://127.0.0.1:$rustfs_api_port"