Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 8d02116

Browse files
Build docker-app CLI plugin for arm platform and release it with other platforms.
Signed-off-by: Silvin Lubecki <[email protected]>
1 parent 85c8094 commit 8d02116

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM dockercore/golang-cross:1.12.9@sha256:3ea9dcef4dd2c46d80445c0b22d6177817f4cfce22c523cc12a5a1091cb37705 AS cli-build
22
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
33
ARG CLI_CHANNEL=stable
4-
ARG CLI_VERSION=19.03.4
4+
ARG CLI_VERSION=19.03.5
55

66
RUN apt-get install -y -q --no-install-recommends \
77
coreutils \
@@ -13,6 +13,7 @@ WORKDIR /go/src/github.com/docker/cli
1313
RUN git clone https://github.com/docker/cli . && git checkout v${CLI_VERSION}
1414
RUN mkdir build
1515
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/x86_64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-amd64 && chmod +x build/docker-linux-amd64
16+
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/aarch64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-arm64 && chmod +x build/docker-linux-arm64
1617
RUN curl -fL https://download.docker.com/mac/static/${CLI_CHANNEL}/x86_64/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-darwin-amd64
1718

1819
ARG GOPROXY
@@ -45,7 +46,7 @@ RUN mkdir $GOPATH/src/gotest.tools && \
4546
ln -s gotestsum-linux /usr/local/bin/gotestsum
4647
# Source for cmd/test2json is part of the Go distribution and is
4748
# therefore available in the base image.
48-
RUN GOOS=linux go build -o /usr/local/bin/test2json-linux cmd/test2json && \
49+
RUN GOOS=linux go build -o /usr/local/bin/test2json-linux cmd/test2json && \
4950
GOOS=darwin go build -o /usr/local/bin/test2json-darwin cmd/test2json && \
5051
GOOS=windows go build -o /usr/local/bin/test2json-windows.exe cmd/test2json
5152
RUN go get -d gopkg.in/mjibson/esc.v0 && \
@@ -66,6 +67,7 @@ RUN make TAG=${TAG} cross
6667
FROM scratch AS cross
6768
ARG PROJECT_PATH=/go/src/github.com/docker/app
6869
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux docker-app-linux
70+
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux-arm64 docker-app-linux-arm64
6971
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-darwin docker-app-darwin
7072
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-windows.exe docker-app-windows.exe
7173

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ check_go_env:
3737

3838
cross: cross-plugin ## cross-compile binaries (linux, darwin, windows)
3939

40-
cross-plugin: bin/$(BIN_NAME)-linux bin/$(BIN_NAME)-darwin bin/$(BIN_NAME)-windows.exe
40+
cross-plugin: bin/$(BIN_NAME)-linux bin/$(BIN_NAME)-darwin bin/$(BIN_NAME)-windows.exe bin/$(BIN_NAME)-linux-arm64
4141

4242
e2e-cross: bin/$(BIN_NAME)-e2e-linux bin/$(BIN_NAME)-e2e-darwin bin/$(BIN_NAME)-e2e-windows.exe
4343

@@ -49,6 +49,10 @@ dynamic: bin/$(BIN_NAME)
4949
bin/$(BIN_NAME)-e2e-%.exe bin/$(BIN_NAME)-e2e-%: e2e bin/$(BIN_NAME)-%
5050
GOOS=$* $(GO_TEST) -c -o $@ ./e2e/
5151

52+
.PHONY: bin/$(BIN_NAME)-linux-arm64
53+
bin/$(BIN_NAME)-linux-arm64: cmd/$(BIN_NAME) check_go_env
54+
GOOS=linux GOARCH=arm64 $(GO_BUILD) -o $@ ./$<
55+
5256
.PHONY: bin/$(BIN_NAME)-windows
5357
bin/$(BIN_NAME)-%.exe bin/$(BIN_NAME)-%: cmd/$(BIN_NAME) check_go_env
5458
GOOS=$* $(GO_BUILD) -o $@ ./$<

docker.Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ shell: build_dev_image ## run a shell in the docker build image
3939
cross: create_bin ## cross-compile binaries (linux, darwin, windows)
4040
docker build $(BUILD_ARGS) --output type=local,dest=./bin/ --target=cross -t $(CROSS_IMAGE_NAME) .
4141
@$(call chmod,+x,bin/$(BIN_NAME)-linux)
42+
@$(call chmod,+x,bin/$(BIN_NAME)-linux-arm64)
4243
@$(call chmod,+x,bin/$(BIN_NAME)-darwin)
4344
@$(call chmod,+x,bin/$(BIN_NAME)-windows.exe)
4445

@@ -60,6 +61,7 @@ e2e-cross: create_bin
6061
tars:
6162
tar --transform='flags=r;s|$(BIN_NAME)-linux|$(BIN_NAME)-plugin-linux|' -czf bin/$(BIN_NAME)-linux.tar.gz -C bin $(BIN_NAME)-linux
6263
tar czf bin/$(BIN_NAME)-e2e-linux.tar.gz -C bin $(BIN_NAME)-e2e-linux
64+
tar --transform='flags=r;s|$(BIN_NAME)-linux-arm64|$(BIN_NAME)-plugin-linux-arm64|' -czf bin/$(BIN_NAME)-linux-arm64.tar.gz -C bin $(BIN_NAME)-linux-arm64
6365
tar --transform='flags=r;s|$(BIN_NAME)-darwin|$(BIN_NAME)-plugin-darwin|' -czf bin/$(BIN_NAME)-darwin.tar.gz -C bin $(BIN_NAME)-darwin
6466
tar czf bin/$(BIN_NAME)-e2e-darwin.tar.gz -C bin $(BIN_NAME)-e2e-darwin
6567
tar --transform='flags=r;s|$(BIN_NAME)-windows|$(BIN_NAME)-plugin-windows|' -czf bin/$(BIN_NAME)-windows.tar.gz -C bin $(BIN_NAME)-windows.exe

0 commit comments

Comments
 (0)