Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions docker/kubernetes-agent-tentacle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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=""
Expand Down
Original file line number Diff line number Diff line change
@@ -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="/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 "/bootstrapRunner"/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" "$@"