From 8460a61f993ccb9604de95fa681859fcf4afcee4 Mon Sep 17 00:00:00 2001 From: Cal Luy Date: Thu, 11 Sep 2025 12:58:04 +1000 Subject: [PATCH 1/2] Enable multi architecture compatibility between Tentacle and Script pods --- docker/kubernetes-agent-tentacle/Dockerfile | 19 +++++-- .../bootstrapRunner/select-bootstrapRunner.sh | 50 +++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) create mode 100755 docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh diff --git a/docker/kubernetes-agent-tentacle/Dockerfile b/docker/kubernetes-agent-tentacle/Dockerfile index e6d28f6fb..c599ce42c 100644 --- a/docker/kubernetes-agent-tentacle/Dockerfile +++ b/docker/kubernetes-agent-tentacle/Dockerfile @@ -9,8 +9,19 @@ ARG TARGETOS COPY docker/kubernetes-agent-tentacle/bootstrapRunner/* /bootstrapRunner/ WORKDIR /bootstrapRunner +# Create bin directory for multiple architectures +RUN mkdir -p bin + +# Build for multiple architectures # Note: the given ldflags remove debug symbols -RUN go build -ldflags "-s -w" -o "bin/bootstrapRunner" +RUN GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "bin/bootstrapRunner-linux-amd64" \ + && GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "bin/bootstrapRunner-linux-arm64" \ + && GOOS=linux GOARCH=386 go build -ldflags "-s -w" -o "bin/bootstrapRunner-linux-386" \ + && GOOS=linux GOARCH=arm go build -ldflags "-s -w" -o "bin/bootstrapRunner-linux-arm" + +# Copy the architecture detection script from source and make it executable +COPY docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh bin/ +RUN chmod +x bin/select-bootstrapRunner.sh FROM mcr.microsoft.com/dotnet/runtime-deps:$RuntimeDepsTag @@ -24,8 +35,8 @@ ARG TARGETVARIANT EXPOSE 10933 COPY docker/kubernetes-agent-tentacle/scripts/* /scripts/ -COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/bootstrapRunner /bootstrapRunner -RUN chmod +x /scripts/*.sh +COPY --from=bootstrapRunnerBuilder bootstrapRunner/bin/* /bootstrapRunner/ +RUN chmod +x /scripts/*.sh && chmod +x /bootstrapRunner/* WORKDIR /tmp @@ -60,7 +71,7 @@ RUN chgrp -R 0 /opt /usr /.dotnet && \ RUN chgrp 0 /etc /etc/ssl/certs && \ chmod g=u /etc /etc/ssl/certs -ENV BOOTSTRAPRUNNEREXECUTABLEPATH=/bootstrapRunner +ENV BOOTSTRAPRUNNEREXECUTABLEPATH=/bootstrapRunner/select-bootstrapRunner.sh ENV OCTOPUS_RUNNING_IN_CONTAINER=Y ENV ACCEPT_EULA=N ENV CustomPublicHostName="" diff --git a/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh b/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh new file mode 100755 index 000000000..3bdc0be44 --- /dev/null +++ b/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -eu + +# Architecture detection and bootstrap runner selection script +# This script automatically detects the runtime architecture and selects +# the appropriate bootstrapRunner binary for execution. + +# Detect the current architecture +ARCH=$(uname -m) +OS=$(uname -s | tr '[:upper:]' '[:lower:]') + +# Map architecture names to Go architecture naming +case "$ARCH" in + x86_64) + GO_ARCH="amd64" + ;; + aarch64|arm64) + GO_ARCH="arm64" + ;; + i386|i686) + GO_ARCH="386" + ;; + armv7l|armv6l) + GO_ARCH="arm" + ;; + *) + echo "Error: Unsupported architecture: $ARCH" >&2 + echo "Supported architectures: x86_64, aarch64, arm64, i386, i686, armv7l, armv6l" >&2 + exit 1 + ;; +esac + +# Construct binary name +BINARY_NAME="bootstrapRunner-${OS}-${GO_ARCH}" +BINARY_PATH="$(dirname "$0")/$BINARY_NAME" + +# Check if the binary exists +if [ ! -f "$BINARY_PATH" ]; then + echo "Error: Bootstrap runner binary not found for architecture ${OS}-${GO_ARCH}" >&2 + echo "Looking for: $BINARY_PATH" >&2 + echo "Available binaries:" >&2 + ls -1 "$(dirname "$0")"/bootstrapRunner-* 2>/dev/null || echo " No bootstrap binaries found" >&2 + exit 1 +fi + +# Make sure the binary is executable +chmod +x "$BINARY_PATH" + +# Execute the appropriate binary with all arguments passed through +exec "$BINARY_PATH" "$@" \ No newline at end of file From f228955159866e098c6a8f97c8a0bd4f376cc3ef Mon Sep 17 00:00:00 2001 From: Cal Luy Date: Fri, 12 Sep 2025 13:56:11 +1000 Subject: [PATCH 2/2] Hard code path --- .../bootstrapRunner/select-bootstrapRunner.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh b/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh index 3bdc0be44..cbef9032d 100755 --- a/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh +++ b/docker/kubernetes-agent-tentacle/bootstrapRunner/select-bootstrapRunner.sh @@ -32,14 +32,14 @@ esac # Construct binary name BINARY_NAME="bootstrapRunner-${OS}-${GO_ARCH}" -BINARY_PATH="$(dirname "$0")/$BINARY_NAME" +BINARY_PATH="/bootstrapRunner/$BINARY_NAME" # Check if the binary exists if [ ! -f "$BINARY_PATH" ]; then echo "Error: Bootstrap runner binary not found for architecture ${OS}-${GO_ARCH}" >&2 echo "Looking for: $BINARY_PATH" >&2 echo "Available binaries:" >&2 - ls -1 "$(dirname "$0")"/bootstrapRunner-* 2>/dev/null || echo " No bootstrap binaries found" >&2 + ls -1 "/bootstrapRunner"/bootstrapRunner-* 2>/dev/null || echo " No bootstrap binaries found" >&2 exit 1 fi