Skip to content
Closed
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
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM crazymax/osxcross:15.5-debian AS osxcross

FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder-base
COPY --from=xx / /
RUN apk add --no-cache clang zig
RUN apk add --no-cache clang zig upx
WORKDIR /src
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=go.mod,target=go.mod \
Expand All @@ -37,6 +37,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build,id=go-build-$TARGETPLATFORM
xx-go build -trimpath -tags no_audio -ldflags "-s -w -linkmode=external -X 'github.com/docker/docker-agent/pkg/version.Version=$GIT_TAG' -X 'github.com/docker/docker-agent/pkg/version.Commit=$GIT_COMMIT'" -o /binaries/docker-agent-$TARGETOS-$TARGETARCH .
xx-verify --static /binaries/docker-agent-$TARGETOS-$TARGETARCH
EOT
RUN upx /binaries/docker-agent-$TARGETOS-$TARGETARCH && \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] UPX arm64 compatibility depends on version — build may fail for linux/arm64

UPX support for linux/arm64 ELF binaries was only added in UPX 4.0 (2023). Alpine's apk add upx installs whatever version the Alpine release ships:

  • Alpine 3.17 and earlier → UPX 3.x → no arm64 supportupx will fail at build time with CantPackException: bad ELF e_machine when TARGETARCH=arm64
  • Alpine 3.18+ → UPX 4.x → arm64 supported

The Dockerfile pins ALPINE_VERSION="3.22", so today this is fine. However:

  1. There is no floor on the UPX version, so a future Alpine base image re-tag that ships an older UPX could silently break linux/arm64 builds.
  2. The PR description notes the binary was tested at ~114 MB → ~30 MB but does not explicitly confirm arm64 (TARGETARCH=arm64) was part of the test run.

Suggested mitigation: Add an explicit upx --version check or pin the upx version (e.g., apk add upx~=4) to ensure arm64 support is guaranteed, and confirm the test plan covers both linux/amd64 and linux/arm64.

upx -t /binaries/docker-agent-$TARGETOS-$TARGETARCH

FROM builder-base AS builder-cross
ARG TARGETPLATFORM
Expand Down
Loading