Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ jobs:
platforms: linux/amd64,linux/arm64
push: false
sbom: false
provenance: false
build-args: |
GIT_TAG=pr
GIT_COMMIT=dev
cache-from: type=gha,scope=buildx
cache-to: type=gha,mode=max,scope=buildx
cache-to: type=gha,mode=min,scope=buildx

build-and-push-image:
if: github.event_name != 'pull_request'
Expand Down
26 changes: 22 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
ENV CGO_ENABLED=1

FROM builder-base AS builder
FROM builder-base AS builder-linux
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=cache,target=/var/cache/apk,id=apk-$TARGETPLATFORM,sharing=locked \
xx-apk add musl-dev
COPY . ./
ARG GIT_TAG
ARG GIT_COMMIT
RUN --mount=type=cache,target=/root/.cache/go-build,id=go-build-$TARGETPLATFORM \
--mount=type=cache,target=/go/pkg/mod <<EOT
set -ex
test "$TARGETOS" = "linux"
export XX_GO_PREFER_C_COMPILER=zig
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

FROM builder-base AS builder-cross
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
Expand All @@ -45,10 +63,10 @@ EOT

FROM scratch AS local
ARG TARGETOS TARGETARCH
COPY --from=builder /binaries/docker-agent-$TARGETOS-$TARGETARCH* docker-agent
COPY --from=builder-cross /binaries/docker-agent-$TARGETOS-$TARGETARCH* docker-agent

FROM scratch AS cross
COPY --from=builder /binaries .
COPY --from=builder-cross /binaries .

FROM alpine:${ALPINE_VERSION}
RUN apk add --no-cache ca-certificates docker-cli && \
Expand All @@ -58,7 +76,7 @@ ARG TARGETOS TARGETARCH
ENV DOCKER_MCP_IN_CONTAINER=1
ENV TERM=xterm-256color
COPY --from=docker/mcp-gateway:v2 /docker-mcp /usr/local/lib/docker/cli-plugins/
COPY --from=builder /binaries/docker-agent-$TARGETOS-$TARGETARCH /docker-agent
COPY --from=builder-linux /binaries/docker-agent-$TARGETOS-$TARGETARCH /docker-agent
USER docker-agent
WORKDIR /work
ENTRYPOINT ["/docker-agent"]
Loading