From e46a80fe30216419886bf2a6c237ff781d7d7044 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Sat, 7 Nov 2026 23:33:18 +0100 Subject: [PATCH] fix(agent): repair installation and release paths (Refs #293) --- docker/Dockerfile.agent | 11 ++- docker/Dockerfile.agent.gpu | 11 ++- .../docker-compose.agent.dev.gpu-nvidia.yml | 2 + docker/docker-compose.agent.dev.yml | 3 + docs/agent-release-signing.md | 2 + docs/docker-compose.md | 11 +++ docs/gitea-builds.md | 2 +- install/install-agent.ps1 | 1 + install/install-agent.sh | 1 + readme.md | 3 + skills/agent-update-acceptance/SKILL.md | 32 ++++++ skills/release-automation/SKILL.md | 1 + .../Services/DockerUpdateService.cs | 4 + .../Components/Pages/SiteDetail.razor | 4 - .../Components/SiteInstallPanel.razor | 97 ++++++++++++++++--- .../Localization/SharedResources.en.resx | 11 ++- .../Localization/SharedResources.fr.resx | 11 ++- .../Localization/SharedResources.resx | 11 ++- 18 files changed, 192 insertions(+), 26 deletions(-) diff --git a/docker/Dockerfile.agent b/docker/Dockerfile.agent index 00f2962..02ca22d 100644 --- a/docker/Dockerfile.agent +++ b/docker/Dockerfile.agent @@ -12,12 +12,19 @@ RUN dotnet publish src/Heimdall.Agent/Heimdall.Agent.csproj -c Release --no-rest FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble@sha256:de0ee358cdd672f7017a003bed21e9ac9ed48a27c922a59b18175b6e82fa7fee WORKDIR /app +ARG DOCKER_CLI_VERSION=29.9.3 +ARG DOCKER_CLI_SHA256=3fb5d1f13014c18cc54945bc177c58a9056a482dada031e17d12cf2e6922c973 RUN apt-get update -qq \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --only-upgrade apt libapt-pkg6.0t64 \ && apt_version="$(dpkg-query -W -f='${Version}' apt)" \ && dpkg --compare-versions "$apt_version" ge 2.8.4ubuntu0.1 \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ffmpeg wget libgomp1 tzdata \ - && rm -rf /var/lib/apt/lists/* + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl ffmpeg wget libgomp1 tzdata \ + && curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 \ + "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz" -o /tmp/docker-cli.tgz \ + && echo "${DOCKER_CLI_SHA256} /tmp/docker-cli.tgz" | sha256sum --check \ + && tar -xzf /tmp/docker-cli.tgz -C /tmp docker/docker \ + && install -m 0755 /tmp/docker/docker /usr/local/bin/docker \ + && rm -rf /tmp/docker /tmp/docker-cli.tgz /var/lib/apt/lists/* RUN install -d -m 0700 -o 1654 -g 1654 /var/lib/heimdall ENV ASPNETCORE_URLS=http://127.0.0.1:8080 COPY --from=build /out/ ./ diff --git a/docker/Dockerfile.agent.gpu b/docker/Dockerfile.agent.gpu index 3b8ff72..2c328e9 100644 --- a/docker/Dockerfile.agent.gpu +++ b/docker/Dockerfile.agent.gpu @@ -13,6 +13,8 @@ FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble@sha256:de0ee358cdd672f7017a003be FROM nvidia/cuda:12.8.1-cudnn-runtime-ubuntu24.04@sha256:9175fa92f96de35a8cfb9493f0dfcf9435c7a597e9d95ad41d2cae382a95e3f9 AS runtime WORKDIR /app +ARG DOCKER_CLI_VERSION=29.9.3 +ARG DOCKER_CLI_SHA256=3fb5d1f13014c18cc54945bc177c58a9056a482dada031e17d12cf2e6922c973 ENV DOTNET_ROOT=/usr/share/dotnet \ PATH=/usr/share/dotnet:$PATH \ LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/lib/x86_64-linux-gnu \ @@ -24,8 +26,13 @@ RUN apt-get update -qq \ && apt_version="$(dpkg-query -W -f='${Version}' apt)" \ && dpkg --compare-versions "$apt_version" ge 2.8.4ubuntu0.1 \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - ca-certificates ffmpeg libgomp1 libicu74 libssl3t64 tzdata wget zlib1g \ - && rm -rf /var/lib/apt/lists/* \ + ca-certificates curl ffmpeg libgomp1 libicu74 libssl3t64 tzdata wget zlib1g \ + && curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 \ + "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz" -o /tmp/docker-cli.tgz \ + && echo "${DOCKER_CLI_SHA256} /tmp/docker-cli.tgz" | sha256sum --check \ + && tar -xzf /tmp/docker-cli.tgz -C /tmp docker/docker \ + && install -m 0755 /tmp/docker/docker /usr/local/bin/docker \ + && rm -rf /tmp/docker /tmp/docker-cli.tgz /var/lib/apt/lists/* \ && install -d -m 0700 -o 1654 -g 1654 /var/lib/heimdall COPY --from=dotnet-runtime /usr/share/dotnet/ /usr/share/dotnet/ COPY --from=build /out/ ./ diff --git a/docker/docker-compose.agent.dev.gpu-nvidia.yml b/docker/docker-compose.agent.dev.gpu-nvidia.yml index f52e4b3..0481bfb 100644 --- a/docker/docker-compose.agent.dev.gpu-nvidia.yml +++ b/docker/docker-compose.agent.dev.gpu-nvidia.yml @@ -10,6 +10,8 @@ services: dockerfile: docker/Dockerfile.agent.gpu environment: Agent__InferenceExecutionProvider: CUDA + volumes: + - /var/run/docker.sock:/var/run/docker.sock deploy: resources: reservations: diff --git a/docker/docker-compose.agent.dev.yml b/docker/docker-compose.agent.dev.yml index 8da30ad..9d2b374 100644 --- a/docker/docker-compose.agent.dev.yml +++ b/docker/docker-compose.agent.dev.yml @@ -7,6 +7,8 @@ services: dockerfile: docker/Dockerfile.agent restart: unless-stopped user: "1654:1654" + group_add: + - "${DOCKER_GID:-0}" network_mode: host environment: ASPNETCORE_URLS: http://127.0.0.1:8081 @@ -19,6 +21,7 @@ services: Agent__StateDirectory: /var/lib/heimdall volumes: - agent_state:/var/lib/heimdall + - /var/run/docker.sock:/var/run/docker.sock healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8081/healthz"] interval: 30s diff --git a/docs/agent-release-signing.md b/docs/agent-release-signing.md index b5e7bcb..ccd1422 100644 --- a/docs/agent-release-signing.md +++ b/docs/agent-release-signing.md @@ -18,6 +18,8 @@ Configurer également la variable Gitea Actions `RELEASE_SERVER_URL` avec l’or La publication génère `agent-update-manifest.json`, qui lie la version, les SHA-256 des archives Agent, l’image CPU et son digest, ainsi que l’image NVIDIA CUDA optionnelle et son digest. Les fichiers `agent-image.json` et `agent-image-gpu.json` contiennent ces références et leur SHA-256 est listé dans `SHA256SUMS`. Elle publie aussi `agent-update-manifest.sig`, signature ECDSA/SHA-256 du fichier JSON. La clé publique permet de vérifier ces valeurs avant tout remplacement d’agent. Une modification de l’URL de la forge ou du registre reste possible sans changer cette clé. +Avant de générer ou mettre à jour un Agent, configurer dans Central le réglage global `updates.releaseapiurl` avec l’URL HTTPS de l’API de la dernière release Gitea publiée, par exemple `https://sources.tordais.cc/api/v1/repos/arnaud.dartois/Heimdall/releases/latest`. Le panneau d’installation Docker n’affiche le Compose que si cette API retourne une image et un digest signés. Les builds de `main` publient les images continues, mais ne créent pas de release Agent; il faut pousser un tag SemVer, attendre le brouillon, puis le promouvoir pour que l’API `latest` le serve. + Les mises à jour automatiques natives sont désactivées par défaut dans les réglages globaux Agent; chaque site peut hériter de ce réglage ou le remplacer. L’Agent vérifie les releases toutes les 12 heures et attend que `publishedAt` ait au moins 24 heures avant d’appliquer une mise à jour automatique. Une demande manuelle d’administrateur peut déclencher la mise à jour immédiatement. Les installations Docker/Kubernetes ne font pas de polling d’image local : elles suivent le mécanisme de l’orchestrateur et le digest fourni par l’IHM. ## Installer un Agent natif diff --git a/docs/docker-compose.md b/docs/docker-compose.md index 7ec2aef..294b5eb 100644 --- a/docs/docker-compose.md +++ b/docs/docker-compose.md @@ -148,6 +148,17 @@ local Central URL. The published Agent image uses CPU inference. The optional NVIDIA, AMD and Intel overlays expose hardware for inventory; they do not enable GPU inference. +Docker Agents mount `/var/run/docker.sock` so the Agent can pull and replace its +container when Central dispatches an update. This socket grants broad control +of the Docker host, effectively host-administrator access. Keep it only on +hosts where that trust is acceptable. The Agent image includes the Docker CLI +client; it does not run a Docker daemon. Updates preserve the previous image +for rollback if the replacement fails its health check. On Linux, start the +generated Compose with `DOCKER_GID="$(stat -c '%g' /var/run/docker.sock)" +docker compose up -d` so the non-root Agent process can access hosts whose +socket is owned by the Docker group. The UI's `docker run` command determines +this group ID from the host socket automatically. + ## Optional software Start Central first to create the shared `heimdall-net` network. Optional diff --git a/docs/gitea-builds.md b/docs/gitea-builds.md index 241492a..b51b22e 100644 --- a/docs/gitea-builds.md +++ b/docs/gitea-builds.md @@ -25,7 +25,7 @@ Après validation de `verify` sur `main`, chaque job d'image publie son tag immu Aucun tag Git n'est requis. Les PR ne reçoivent pas de secret de publication et ne poussent aucune image. Le namespace `eltruncho` correspond au Compose de production actuel. Les secrets d'organisation `DOCKERHUB_USERNAME` et `DOCKERHUB_TOKEN` doivent être disponibles ; le token doit autoriser l'écriture dans les deux dépôts Docker Hub. Les identifiants sont transmis par stdin à `docker login` et stockés seulement dans une configuration temporaire supprimée en sortie. -Les tags Git `vMAJOR.MINOR.PATCH[-prerelease]` conservent le job séparé de release, après validation de `verify`. Le job reconstruit et scanne les trois images, puis publie les images CPU et CUDA de l’Agent et joint leurs manifestes au manifeste ECDSA signé. Il nécessite en plus `DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN`, `RELEASE_TOKEN` et `RELEASE_SIGNING_KEY_B64`. La release reste en brouillon jusqu'à promotion explicite. +Les tags Git `vMAJOR.MINOR.PATCH[-prerelease]` lancent le job séparé de release, après validation de `verify`. Un build réussi sur `main` ne crée pas de release Gitea : il publie les images `latest` et `sha-*` seulement. Pour préparer une version depuis le commit validé de `main`, créer et pousser un tag, par exemple `git tag -a v1.2.3 -m "Heimdall v1.2.3" && git push origin v1.2.3`. Le tag doit respecter la forme SemVer et viser un commit de `main`. Le job reconstruit et scanne les trois images, puis publie les images CPU et CUDA de l’Agent et joint leurs manifestes au manifeste ECDSA signé. Il nécessite en plus `DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN`, `RELEASE_TOKEN` et `RELEASE_SIGNING_KEY_B64`. La release Gitea reste en brouillon jusqu'à promotion explicite. Aucun tag n’existe encore sur le dépôt; aucun run de release tagué n’a donc eu lieu. ## Renovate diff --git a/install/install-agent.ps1 b/install/install-agent.ps1 index ba6a287..8e1916d 100644 --- a/install/install-agent.ps1 +++ b/install/install-agent.ps1 @@ -234,6 +234,7 @@ try { "Agent__SiteToken=$SiteToken", "Agent__AgentName=$AgentName", "Agent__StateDirectory=$stateDirectory", + "MODEL_PATH=$(Join-Path $releasePath 'models\yolov8n.onnx')", "Agent__UpdateInstallRoot=$releaseRoot", "Agent__UpdatePublicKeyPath=$publicKeyPath", "Agent__UpdateSupervisorPath=$supervisorPath", diff --git a/install/install-agent.sh b/install/install-agent.sh index c973d11..a209b84 100755 --- a/install/install-agent.sh +++ b/install/install-agent.sh @@ -151,6 +151,7 @@ if [[ "$RUN_MODE" == true ]]; then HEIMDALL_DOTNET="$DOTNET_BIN" \ ASPNETCORE_ENVIRONMENT=Production \ Agent__CentralUrl="$CENTRAL_URL" \ + Agent__AgentName="$AGENT_NAME" \ Agent__AllowInsecureHttp="$ALLOW_INSECURE_HTTP" \ Agent__StateDirectory="$STATE_DIR" \ Agent__UpdateInstallRoot="$INSTALL_ROOT" \ diff --git a/readme.md b/readme.md index ca3f0dd..788c0e3 100644 --- a/readme.md +++ b/readme.md @@ -90,6 +90,9 @@ peut créer un service Windows (PowerShell administrateur requis). Pour Docker, utilisez le Compose généré par l’IHM, épinglé au digest signé. Aucun fichier de clé ni Compose de production ne doit être copié depuis le dépôt. Voir le [guide de signature et de mise à jour Agent](docs/agent-release-signing.md). +Le Compose Docker monte le socket Docker de l’hôte pour permettre les mises à +jour pilotées par Central; ce socket donne à l’Agent un contrôle étendu sur +l’hôte. N’installez ce mode que sur un hôte de confiance. ### 3. Développement local diff --git a/skills/agent-update-acceptance/SKILL.md b/skills/agent-update-acceptance/SKILL.md index 3fdeab4..5474136 100644 --- a/skills/agent-update-acceptance/SKILL.md +++ b/skills/agent-update-acceptance/SKILL.md @@ -7,6 +7,38 @@ description: Validate Heimdall native Agent install, signed update, startup heal Use this skill when changing `install/install-agent.sh`, `install/install-agent.ps1`, `install/agent-supervisor.py`, or `install/agent-update-supervisor.ps1`. +For Docker Agent install/update changes, also inspect the generated Compose and +`docker run` commands in `SiteInstallPanel.razor`, plus both CPU and NVIDIA +Agent images. The Docker updater shells out to the Docker CLI and therefore +requires the CLI in the image and `/var/run/docker.sock` mounted into the +container. Validate the generated Compose and Docker-run command together; +document that mounting this socket grants broad control of the host. The Docker +Run panel must provide POSIX and PowerShell commands, use an immutable signed +image reference, initialize the state volume, and keep the health endpoint +reachable for update rollback checks. A disposable image acceptance should +build with a project-unique tag and assert `docker --version` inside the image, +then remove and verify absence of that exact tag. When Compose has multiple +services using the built Agent image, the acceptance override must retag every +service, including one-shot volume initialization, so it does not create an +untracked `:local` image. + +For Windows Service installation, set `MODEL_PATH` to the installed +`current\models\yolov8n.onnx` path because the Service Control Manager does not +start services from the Agent release directory. Validate the service's model +path, enrollment, startup, signed update, and rollback on a real Windows host; +PowerShell parsing on Linux is not a substitute for that run. + +For Linux systemd installs, preserve the site display name through the existing +`LoadCredential=agent-name` credential and `AgentOptions` fallback. The +foreground installer may pass `Agent__AgentName` directly; do not put arbitrary +site names in an unescaped systemd `Environment=` assignment. + +Before accepting a native or Docker install flow, verify that Central's global +`updates.releaseapiurl` points to an HTTPS Gitea `releases/latest` API with a +published release containing the signed manifest, asset checksums, and required +image digest. A `main` Docker image build alone cannot supply the signed Agent +release metadata used by installers and the IHM. + ## Linux rollback simulation - Run `python3 -m unittest discover -s scripts/ci -p 'test_*.py' -k supervisor_rolls_back_failed_startup_to_previous_release`. diff --git a/skills/release-automation/SKILL.md b/skills/release-automation/SKILL.md index 669fea0..0963532 100644 --- a/skills/release-automation/SKILL.md +++ b/skills/release-automation/SKILL.md @@ -14,6 +14,7 @@ Use this skill for changes to `scripts/ci/package.sh`, `publish.sh`, `release-gi - Use a dedicated Gitea `RELEASE_TOKEN`, Docker Hub credentials, and a base64 encoded ECDSA P-256 key only in the tagged release job. Never make them available to PR jobs or print them. - Do not overwrite published image tags owned by another commit or mutate an already published Gitea release. Releases remain drafts until an operator promotes them. - The release includes deterministic Web and Agent archives, provenance, checksums, the public key, immutable image digests, and a signed Agent update manifest. +- A successful `main` build publishes Docker `latest` and immutable `sha-*` images but does not create a Gitea release. An operator starts versioned publication by pushing a SemVer tag (`git tag -a vX.Y.Z ... && git push origin vX.Y.Z`) that points to a commit on `main`. ## Offline end-to-end acceptance diff --git a/src/Heimdall.Agent/Services/DockerUpdateService.cs b/src/Heimdall.Agent/Services/DockerUpdateService.cs index d2a4e91..e853d65 100644 --- a/src/Heimdall.Agent/Services/DockerUpdateService.cs +++ b/src/Heimdall.Agent/Services/DockerUpdateService.cs @@ -162,6 +162,7 @@ public sealed class DockerUpdateService : BackgroundService if (!string.IsNullOrEmpty(c.NetworkMode)) a.AddRange(["--network", c.NetworkMode]); if (!string.IsNullOrEmpty(c.RestartPolicy)) a.AddRange(["--restart", c.RestartPolicy]); foreach (var e in c.Environment) a.AddRange(["-e", e]); + foreach (var group in c.Groups) a.AddRange(["--group-add", group]); foreach (var p in c.Ports) a.AddRange(["-p", p]); foreach (var v in c.Volumes) a.AddRange(["-v", v]); foreach (var d in c.Devices) a.AddRange(["--device", d]); @@ -292,6 +293,7 @@ public sealed class DockerUpdateService : BackgroundService c.CapAdd.AddRange(HostConfig.CapAdd ?? []); c.CapDrop.AddRange(HostConfig.CapDrop ?? []); c.SecurityOptions.AddRange(HostConfig.SecurityOptions ?? []); + c.Groups.AddRange(HostConfig.GroupAdd ?? []); c.Privileged = HostConfig.Privileged; c.IpcMode = HostConfig.IpcMode; c.PidMode = HostConfig.PidMode; @@ -312,6 +314,7 @@ public sealed class DockerUpdateService : BackgroundService [JsonPropertyName("CapAdd")] public List? CapAdd { get; init; } [JsonPropertyName("CapDrop")] public List? CapDrop { get; init; } [JsonPropertyName("SecurityOpt")] public List? SecurityOptions { get; init; } + [JsonPropertyName("GroupAdd")] public List? GroupAdd { get; init; } [JsonPropertyName("Privileged")] public bool Privileged { get; init; } [JsonPropertyName("IpcMode")] public string? IpcMode { get; init; } [JsonPropertyName("PidMode")] public string? PidMode { get; init; } @@ -350,6 +353,7 @@ internal sealed class ContainerConfig public string? ImageId { get; set; } public string? User { get; set; } public List Environment { get; set; } = []; + public List Groups { get; set; } = []; public List Ports { get; set; } = []; public List Volumes { get; set; } = []; public List Devices { get; set; } = []; diff --git a/src/Heimdall.Web/Components/Pages/SiteDetail.razor b/src/Heimdall.Web/Components/Pages/SiteDetail.razor index 6ccd3a4..c31b484 100644 --- a/src/Heimdall.Web/Components/Pages/SiteDetail.razor +++ b/src/Heimdall.Web/Components/Pages/SiteDetail.razor @@ -253,7 +253,6 @@ else private bool _generating; private string? _generatedToken; private DateTime _tokenExpiresAt; - private string _dockerComposeSnippet = ""; // ── Identifiants caméras ────────────────────────────────────── private List _credentials = []; @@ -385,15 +384,12 @@ else } _generatedToken = result.Token; _tokenExpiresAt = result.ExpiresAt; - _dockerComposeSnippet = GenerateDockerComposeSnippet(_generatedToken); Snackbar.Add(Text["SiteDetail_TokenGenerated"], Severity.Warning); } catch { Snackbar.Add(Text["SiteDetail_OperationFailed"], Severity.Error); } finally { _generating = false; } } - private string GenerateDockerComposeSnippet(string token) => ""; - /// Origin exposed by the browser that operators use to reach Central. private string CentralUrl => Nav.BaseUri.TrimEnd('/'); } diff --git a/src/Heimdall.Web/Components/SiteInstallPanel.razor b/src/Heimdall.Web/Components/SiteInstallPanel.razor index 71300a7..d2f75dd 100644 --- a/src/Heimdall.Web/Components/SiteInstallPanel.razor +++ b/src/Heimdall.Web/Components/SiteInstallPanel.razor @@ -64,18 +64,29 @@ else if (_method == "docker-compose" && !CanGenerateDocker) { @Text["SiteInstallPanel_ImageUnavailable"] } - -@Text["SiteInstallPanel_Commands"] -@foreach (var command in Commands) +else if (_method == "docker-run" && CanGenerateDocker) { - @Text[command.Label] - -
@command.Value
-
- - @Text["SiteInstallPanel_CopyCommand"] - + @Text["SiteInstallPanel_DockerUpdateNote"] +} +else if (_method == "docker-run") +{ + @Text["SiteInstallPanel_ImageUnavailable"] +} + +@if (_method != "docker-run" || CanGenerateDocker) +{ + @Text["SiteInstallPanel_Commands"] + @foreach (var command in Commands) + { + @Text[command.Label] + +
@command.Value
+
+ + @Text["SiteInstallPanel_CopyCommand"] + + } } @if (_method == "windows-run") @@ -165,7 +176,10 @@ else if (_method == "windows-service") [ ("SiteInstallPanel_Install", DockerRunInstallCommand), ("SiteInstallPanel_Run", DockerRunCommand), - ("SiteInstallPanel_Check", $"docker inspect --format '{{{{.State.Status}}}}' heimdall-agent-{Slugify(SiteName)} && docker logs --tail 50 heimdall-agent-{Slugify(SiteName)}") + ("SiteInstallPanel_Check", $"docker inspect --format '{{{{.State.Status}}}}' heimdall-agent-{Slugify(SiteName)} && docker logs --tail 50 heimdall-agent-{Slugify(SiteName)}"), + ("SiteInstallPanel_InstallPowerShell", DockerRunPowerShellInstallCommand), + ("SiteInstallPanel_RunPowerShell", DockerRunPowerShellCommand), + ("SiteInstallPanel_CheckPowerShell", DockerRunPowerShellCheckCommand) ]; return []; } @@ -208,6 +222,8 @@ else if (_method == "windows-service") container_name: heimdall-agent-{{safeName}} restart: unless-stopped user: "1654:1654" + group_add: + - "${DOCKER_GID:-0}" network_mode: host environment: Agent__CentralUrl: {{YamlScalar(CentralUrl)}} @@ -219,6 +235,7 @@ else if (_method == "windows-service") Agent__UpdatePublicKeyPem: "{{pem}}" volumes: - agent_state_{{safeName}}:/var/lib/heimdall + - /var/run/docker.sock:/var/run/docker.sock depends_on: agent-state-init: condition: service_completed_successfully @@ -249,8 +266,9 @@ else if (_method == "windows-service") get { var volume = "heimdall-agent-state-" + Slugify(SiteName); - return $"docker pull {_agentImageReference} && docker volume create {volume} && " + - $"docker run --rm --user 0:0 --entrypoint chown -v {volume}:/state {_agentImageReference} -R 1654:1654 /state"; + var image = _useGpuImage ? _agentGpuImageReference : _agentImageReference; + return $"docker pull {image} && docker volume create {volume} && " + + $"docker run --rm --user 0:0 --entrypoint chown -v {volume}:/state {image} -R 1654:1654 /state"; } } @@ -263,6 +281,8 @@ else if (_method == "windows-service") var image = _useGpuImage ? _agentGpuImageReference : _agentImageReference; return $"docker run -d --name {name} --restart unless-stopped --network host --user 1654:1654 " + (_useGpuImage ? "--gpus all " : "") + + "--group-add \"$(stat -c '%g' /var/run/docker.sock)\" " + + "-v /var/run/docker.sock:/var/run/docker.sock " + $"-e Agent__CentralUrl={ShellQuote(CentralUrl)} -e Agent__SiteToken={ShellQuote(SiteToken)} " + $"-e Agent__AgentName={ShellQuote(SiteName)} -e Agent__StateDirectory=/var/lib/heimdall " + $"-e Agent__InferenceExecutionProvider={(_useGpuImage ? "CUDA" : "CPU")} " + @@ -271,6 +291,55 @@ else if (_method == "windows-service") } } + private string DockerRunPowerShellInstallCommand + { + get + { + var volume = "heimdall-agent-state-" + Slugify(SiteName); + var image = _useGpuImage ? _agentGpuImageReference : _agentImageReference; + return "$ErrorActionPreference = 'Stop'; " + + "docker pull " + PowerShellQuote(image ?? "") + "; if ($LASTEXITCODE -ne 0) { throw 'docker pull failed' }; " + + "docker volume create " + PowerShellQuote(volume) + "; if ($LASTEXITCODE -ne 0) { throw 'docker volume create failed' }; " + + "docker run --rm --user 0:0 --entrypoint chown -v " + PowerShellQuote(volume + ":/state") + " " + + PowerShellQuote(image ?? "") + " -R 1654:1654 /state; if ($LASTEXITCODE -ne 0) { throw 'state volume initialization failed' }"; + } + } + + private string DockerRunPowerShellCommand + { + get + { + var name = "heimdall-agent-" + Slugify(SiteName); + var volume = "heimdall-agent-state-" + Slugify(SiteName); + var image = _useGpuImage ? _agentGpuImageReference : _agentImageReference; + var args = new List { "run", "-d", "--name", name, "--restart", "unless-stopped", "--user", "1654:1654", "--publish", "127.0.0.1:8081:8080", "--group-add", "0", "-v", "/var/run/docker.sock:/var/run/docker.sock" }; + if (_useGpuImage) args.AddRange(["--gpus", "all"]); + args.AddRange([ + "-e", "Agent__CentralUrl=" + CentralUrl, + "-e", "Agent__SiteToken=" + SiteToken, + "-e", "Agent__AgentName=" + SiteName, + "-e", "Agent__StateDirectory=/var/lib/heimdall", + "-e", "ASPNETCORE_URLS=http://+:8080", + "-e", "Agent__InferenceExecutionProvider=" + (_useGpuImage ? "CUDA" : "CPU"), + "-e", "Agent__UpdatePublicKeyPem=" + (_updatePublicKeyPem ?? ""), + "-v", volume + ":/var/lib/heimdall", + image ?? "" + ]); + return "$dockerArgs = @(" + string.Join(",", args.Select(PowerShellQuote)) + "); & docker @dockerArgs; if ($LASTEXITCODE -ne 0) { throw 'docker run failed' }"; + } + } + + private string DockerRunPowerShellCheckCommand + { + get + { + var name = "heimdall-agent-" + Slugify(SiteName); + return "$status = docker inspect --format '{{.State.Status}}' " + PowerShellQuote(name) + "; " + + "if ($LASTEXITCODE -ne 0) { throw 'container inspect failed' }; $status; " + + "docker logs --tail 50 " + PowerShellQuote(name) + "; if ($LASTEXITCODE -ne 0) { throw 'container logs failed' }"; + } + } + private string LinuxInstallCommand(bool service) { var baseUrl = CentralUrl.TrimEnd('/'); diff --git a/src/Heimdall.Web/Localization/SharedResources.en.resx b/src/Heimdall.Web/Localization/SharedResources.en.resx index ec33ac9..a98b8dc 100644 --- a/src/Heimdall.Web/Localization/SharedResources.en.resx +++ b/src/Heimdall.Web/Localization/SharedResources.en.resx @@ -4072,7 +4072,7 @@ Check - Update containers through Docker or Kubernetes. Heimdall pins each image to its signed digest. + Container updates use Docker or Kubernetes. Heimdall pins each image to its signed digest. Docker mode mounts the host Docker socket, giving the Agent broad control of that host. On Linux, before Compose, set DOCKER_GID to the socket GID: export DOCKER_GID="$(stat -c '%g' /var/run/docker.sock)". The Agent starts in the background so you can check it from this PowerShell session. Choose Windows Service to restart it after logoff or reboot. @@ -4083,6 +4083,15 @@ Docker Run + + Install (PowerShell) + + + Run (PowerShell) + + + Check (PowerShell) + Use NVIDIA GPU inference diff --git a/src/Heimdall.Web/Localization/SharedResources.fr.resx b/src/Heimdall.Web/Localization/SharedResources.fr.resx index ec8e908..a5572f2 100644 --- a/src/Heimdall.Web/Localization/SharedResources.fr.resx +++ b/src/Heimdall.Web/Localization/SharedResources.fr.resx @@ -4072,7 +4072,7 @@ Vérifier - Les mises à jour des conteneurs passent par Docker ou Kubernetes. Heimdall épingle chaque image sur son digest signé. + Les mises à jour des conteneurs passent par Docker ou Kubernetes. Heimdall épingle chaque image sur son digest signé. Le mode Docker monte le socket Docker de l’hôte, ce qui donne à l’Agent un contrôle étendu sur cet hôte. Sous Linux, avant Compose, définissez DOCKER_GID avec le GID du socket : export DOCKER_GID="$(stat -c '%g' /var/run/docker.sock)". L’Agent démarre en arrière-plan pour permettre la vérification depuis cette console. Le mode Service Windows le relance après fermeture de session ou redémarrage. @@ -4083,6 +4083,15 @@ Docker Run + + Installer (PowerShell) + + + Démarrer (PowerShell) + + + Vérifier (PowerShell) + Utiliser l’inférence GPU NVIDIA diff --git a/src/Heimdall.Web/Localization/SharedResources.resx b/src/Heimdall.Web/Localization/SharedResources.resx index cd2ffe4..7260461 100644 --- a/src/Heimdall.Web/Localization/SharedResources.resx +++ b/src/Heimdall.Web/Localization/SharedResources.resx @@ -4072,7 +4072,7 @@ Check - Update containers through Docker or Kubernetes. Heimdall pins each image to its signed digest. + Container updates use Docker or Kubernetes. Heimdall pins each image to its signed digest. Docker mode mounts the host Docker socket, giving the Agent broad control of that host. On Linux, before Compose, set DOCKER_GID to the socket GID: export DOCKER_GID="$(stat -c '%g' /var/run/docker.sock)". The Agent starts in the background so you can check it from this PowerShell session. Choose Windows Service to restart it after logoff or reboot. @@ -4083,6 +4083,15 @@ Docker Run + + Install (PowerShell) + + + Run (PowerShell) + + + Check (PowerShell) + Use NVIDIA GPU inference -- 2.54.1