From 731a04a3932c93cb944346e3ecc668bf13891485 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Thu, 15 May 2025 10:42:45 +1000 Subject: [PATCH 1/5] Build both amd64 and arm64 builds of the bootstrapRunner --- .nuke/build.schema.json | 2 ++ docker/kubernetes-agent-tentacle/Dockerfile | 7 +++---- docker/kubernetes-agent-tentacle/dev/Dockerfile | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 2ae5a55cd..4d2042de3 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -123,6 +123,7 @@ "PackChocolateyPackage", "PackClient", "PackContracts", + "PackCore", "PackCrossPlatformBundle", "PackDebianPackage", "PackLinux", @@ -172,6 +173,7 @@ "PackChocolateyPackage", "PackClient", "PackContracts", + "PackCore", "PackCrossPlatformBundle", "PackDebianPackage", "PackLinux", diff --git a/docker/kubernetes-agent-tentacle/Dockerfile b/docker/kubernetes-agent-tentacle/Dockerfile index 9c951ad3a..668e51b1e 100644 --- a/docker/kubernetes-agent-tentacle/Dockerfile +++ b/docker/kubernetes-agent-tentacle/Dockerfile @@ -1,7 +1,6 @@ ARG RuntimeDepsTag - -FROM golang:1.22 as bootstrapRunnerBuilder +FROM golang:1.24 AS bootstrapRunnerBuilder ARG TARGETARCH ARG TARGETOS @@ -10,8 +9,8 @@ COPY docker/kubernetes-agent-tentacle/bootstrapRunner/* /bootstrapRunner/ WORKDIR /bootstrapRunner # Note: the given ldflags remove debug symbols -RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner" - +RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/amd64" +RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/arm64" FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag diff --git a/docker/kubernetes-agent-tentacle/dev/Dockerfile b/docker/kubernetes-agent-tentacle/dev/Dockerfile index 73fac5398..4486a3ded 100644 --- a/docker/kubernetes-agent-tentacle/dev/Dockerfile +++ b/docker/kubernetes-agent-tentacle/dev/Dockerfile @@ -1,7 +1,6 @@ ARG RuntimeDepsTag - -FROM golang:1.22 as bootstrapRunnerBuilder +FROM golang:1.24 AS bootstrapRunnerBuilder ARG TARGETARCH ARG TARGETOS @@ -10,8 +9,8 @@ COPY docker/kubernetes-agent-tentacle/bootstrapRunner/* /bootstrapRunner/ WORKDIR /bootstrapRunner # Note: the given ldflags remove debug symbols -RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner" - +RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/amd64" +RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/arm64" FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag From 1b902a05a7644bb81ec6625007974e3d518c07c3 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Thu, 15 May 2025 11:11:34 +1000 Subject: [PATCH 2/5] Copy the each arch individually --- docker/kubernetes-agent-tentacle/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker/kubernetes-agent-tentacle/Dockerfile b/docker/kubernetes-agent-tentacle/Dockerfile index 668e51b1e..fb5834d28 100644 --- a/docker/kubernetes-agent-tentacle/Dockerfile +++ b/docker/kubernetes-agent-tentacle/Dockerfile @@ -9,8 +9,8 @@ COPY docker/kubernetes-agent-tentacle/bootstrapRunner/* /bootstrapRunner/ WORKDIR /bootstrapRunner # Note: the given ldflags remove debug symbols -RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/amd64" -RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/bootstrapRunner/arm64" +RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/amd64/bootstrapRunner" +RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/arm64/bootstrapRunner" FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag @@ -23,7 +23,8 @@ ARG TARGETVARIANT EXPOSE 10933 COPY docker/kubernetes-agent-tentacle/scripts/* /scripts/ -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/bootstrapRunner /bootstrapRunner +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/amd64/bootstrapRunner /bootstrapRunner/amd64 +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/arm64/bootstrapRunner /bootstrapRunner/arm64 RUN chmod +x /scripts/*.sh WORKDIR /tmp From f4654e622ace823c193d27640251a2e8cd9c1d37 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Thu, 15 May 2025 11:28:27 +1000 Subject: [PATCH 3/5] Correctly name the binary --- docker/kubernetes-agent-tentacle/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/kubernetes-agent-tentacle/Dockerfile b/docker/kubernetes-agent-tentacle/Dockerfile index fb5834d28..27dc0663b 100644 --- a/docker/kubernetes-agent-tentacle/Dockerfile +++ b/docker/kubernetes-agent-tentacle/Dockerfile @@ -23,8 +23,8 @@ ARG TARGETVARIANT EXPOSE 10933 COPY docker/kubernetes-agent-tentacle/scripts/* /scripts/ -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/amd64/bootstrapRunner /bootstrapRunner/amd64 -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/arm64/bootstrapRunner /bootstrapRunner/arm64 +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/amd64/bootstrapRunner /bootstrapRunner/amd64/bootstrapRunner +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/arm64/bootstrapRunner /bootstrapRunner/arm64/bootstrapRunner RUN chmod +x /scripts/*.sh WORKDIR /tmp From 002f4589c1ca972f528f32db670307d6e4dd31f6 Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Thu, 15 May 2025 12:18:35 +1000 Subject: [PATCH 4/5] Change to suffix'd files --- docker/kubernetes-agent-tentacle/Dockerfile | 8 ++++---- .../Kubernetes/KubernetesScriptPodCreator.cs | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docker/kubernetes-agent-tentacle/Dockerfile b/docker/kubernetes-agent-tentacle/Dockerfile index 27dc0663b..4e498ac7d 100644 --- a/docker/kubernetes-agent-tentacle/Dockerfile +++ b/docker/kubernetes-agent-tentacle/Dockerfile @@ -9,8 +9,8 @@ COPY docker/kubernetes-agent-tentacle/bootstrapRunner/* /bootstrapRunner/ WORKDIR /bootstrapRunner # Note: the given ldflags remove debug symbols -RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/amd64/bootstrapRunner" -RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/arm64/bootstrapRunner" +RUN env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/bootstrapRunner-amd64" +RUN env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/bootstrapRunner-arm64" FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag @@ -23,8 +23,8 @@ ARG TARGETVARIANT EXPOSE 10933 COPY docker/kubernetes-agent-tentacle/scripts/* /scripts/ -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/amd64/bootstrapRunner /bootstrapRunner/amd64/bootstrapRunner -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/arm64/bootstrapRunner /bootstrapRunner/arm64/bootstrapRunner +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/bootstrapRunner-amd64 /bootstrapRunner-amd64 +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/bootstrapRunner-arm64 /bootstrapRunner-arm64 RUN chmod +x /scripts/*.sh WORKDIR /tmp diff --git a/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs b/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs index 52143e58c..f33737122 100644 --- a/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs +++ b/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs @@ -176,7 +176,8 @@ async Task CreatePod(StartKubernetesScriptCommandV1 command, IScriptWorkspace wo LogVerboseToBothLogs($"Creating Kubernetes Pod '{podName}'.", tentacleScriptLog); - workspace.CopyFile(KubernetesConfig.BootstrapRunnerExecutablePath, "bootstrapRunner", true); + workspace.CopyFile($"{KubernetesConfig.BootstrapRunnerExecutablePath}-amd64", "bootstrapRunner-amd64", true); + workspace.CopyFile($"{KubernetesConfig.BootstrapRunnerExecutablePath}-arm64", "bootstrapRunner-arm64", true); var scriptName = Path.GetFileName(workspace.BootstrapScriptFilePath); var workspacePath = Path.Combine("Work", workspace.ScriptTicket.TaskId); @@ -292,7 +293,7 @@ protected async Task CreateScriptContainer(StartKubernetesScriptCom var commandString = string.Join(" ", new[] { - $"{homeDir}/Work/{command.ScriptTicket.TaskId}/bootstrapRunner", + $"{homeDir}/Work/{command.ScriptTicket.TaskId}/bootstrapRunner-$(arch)", Path.Combine(homeDir, workspacePath), Path.Combine(homeDir, workspacePath, scriptName) }.Concat(scriptArguments ?? Array.Empty()) From 33218bdbb0f043fcd4aeb8db713b9771ff693eeb Mon Sep 17 00:00:00 2001 From: Alastair Pitts Date: Thu, 15 May 2025 12:31:36 +1000 Subject: [PATCH 5/5] Run correct arch --- .../Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs b/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs index f33737122..2bb26df40 100644 --- a/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs +++ b/source/Octopus.Tentacle/Kubernetes/KubernetesScriptPodCreator.cs @@ -293,7 +293,7 @@ protected async Task CreateScriptContainer(StartKubernetesScriptCom var commandString = string.Join(" ", new[] { - $"{homeDir}/Work/{command.ScriptTicket.TaskId}/bootstrapRunner-$(arch)", + $"{homeDir}/Work/{command.ScriptTicket.TaskId}/bootstrapRunner-$(arch | sed -n '/arm/ {{s/.*arm.*/arm/;p;q}}; $a\\amd64')", Path.Combine(homeDir, workspacePath), Path.Combine(homeDir, workspacePath, scriptName) }.Concat(scriptArguments ?? Array.Empty())