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

Commit 1cfb232

Browse files
Merge pull request #777 from silvin-lubecki/arm-build
Introduce Arm64 support
2 parents 012748d + 743f7fc commit 1cfb232

File tree

6 files changed

+65
-13
lines changed

6 files changed

+65
-13
lines changed

Dockerfile

Lines changed: 6 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,8 @@ 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
17+
RUN curl -fL https://download.docker.com/linux/static/${CLI_CHANNEL}/armhf/docker-${CLI_VERSION}.tgz | tar xzO docker/docker > build/docker-linux-arm && chmod +x build/docker-linux-arm
1618
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
1719

1820
ARG GOPROXY
@@ -45,7 +47,7 @@ RUN mkdir $GOPATH/src/gotest.tools && \
4547
ln -s gotestsum-linux /usr/local/bin/gotestsum
4648
# Source for cmd/test2json is part of the Go distribution and is
4749
# therefore available in the base image.
48-
RUN GOOS=linux go build -o /usr/local/bin/test2json-linux cmd/test2json && \
50+
RUN GOOS=linux go build -o /usr/local/bin/test2json-linux cmd/test2json && \
4951
GOOS=darwin go build -o /usr/local/bin/test2json-darwin cmd/test2json && \
5052
GOOS=windows go build -o /usr/local/bin/test2json-windows.exe cmd/test2json
5153
RUN go get -d gopkg.in/mjibson/esc.v0 && \
@@ -66,6 +68,8 @@ RUN make TAG=${TAG} cross
6668
FROM scratch AS cross
6769
ARG PROJECT_PATH=/go/src/github.com/docker/app
6870
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux docker-app-linux
71+
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux-arm64 docker-app-linux-arm64
72+
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-linux-arm docker-app-linux-arm
6973
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-darwin docker-app-darwin
7074
COPY --from=cross-build ${PROJECT_PATH}/bin/docker-app-windows.exe docker-app-windows.exe
7175

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
dir('src/github.com/docker/app') {
7676
checkout scm
7777
ansiColor('xterm') {
78-
sh 'make -f docker.Makefile save-invocation-image'
78+
sh 'make -f docker.Makefile invocation-image save-invocation-image'
7979
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar save-invocation-image-tag'
8080
}
8181
dir('_build') {

Jenkinsfile.baguette

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,29 @@ pipeline {
5959
}
6060
stage('Invocation image'){
6161
agent {
62-
label 'ubuntu-1804'
62+
label 'team-local && windows && linux-containers'
6363
}
6464
steps {
6565
dir('src/github.com/docker/app') {
6666
checkout scm
6767
ansiColor('xterm') {
68-
sh 'make -f docker.Makefile save-invocation-image'
68+
sh 'make -f docker.Makefile invocation-image-cross save-invocation-image-cross'
6969
sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar'
7070
}
7171
dir('_build') {
7272
stash name: 'invocation-image', includes: 'invocation-image.tar'
73+
stash name: 'invocation-image-arm64', includes: 'invocation-image-arm64.tar'
74+
stash name: 'invocation-image-arm', includes: 'invocation-image-arm.tar'
7375
stash name: 'coverage-invocation-image', includes: 'coverage-invocation-image.tar'
74-
archiveArtifacts 'invocation-image.tar'
76+
archiveArtifacts 'invocation-image*.tar'
7577
}
7678
}
7779
}
7880
post {
7981
always {
8082
sh 'docker rmi docker/cnab-app-base:$TAG'
83+
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
84+
sh 'docker rmi docker/cnab-app-base:$TAG-arm'
8185
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
8286
deleteDir()
8387
}
@@ -250,6 +254,10 @@ pipeline {
250254
dir('_build') {
251255
unstash "invocation-image"
252256
sh 'docker load -i invocation-image.tar'
257+
unstash "invocation-image-arm64"
258+
sh 'docker load -i invocation-image-arm64.tar'
259+
unstash "invocation-image-arm"
260+
sh 'docker load -i invocation-image-arm.tar'
253261
}
254262
ansiColor('xterm') {
255263
sh 'make -f docker.Makefile push-invocation-image'
@@ -264,6 +272,8 @@ pipeline {
264272
post {
265273
always {
266274
sh 'docker rmi docker/cnab-app-base:$TAG'
275+
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
276+
sh 'docker rmi docker/cnab-app-base:$TAG-arm'
267277
deleteDir()
268278
}
269279
}

Makefile

Lines changed: 9 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 bin/$(BIN_NAME)-linux-arm
4141

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

@@ -49,6 +49,14 @@ 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+
56+
.PHONY: bin/$(BIN_NAME)-linux-arm
57+
bin/$(BIN_NAME)-linux-arm: cmd/$(BIN_NAME) check_go_env
58+
GOOS=linux GOARCH=arm $(GO_BUILD) -o $@ ./$<
59+
5260
.PHONY: bin/$(BIN_NAME)-windows
5361
bin/$(BIN_NAME)-%.exe bin/$(BIN_NAME)-%: cmd/$(BIN_NAME) check_go_env
5462
GOOS=$* $(GO_BUILD) -o $@ ./$<

docker.Makefile

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ PKG_PATH := /go/src/$(PKG_NAME)
2020

2121

2222
CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(BUILD_TAG)
23-
CNAB_BASE_INVOCATION_IMAGE_PATH := _build/invocation-image.tar
23+
CNAB_BASE_INVOCATION_IMAGE_PATH := _build/invocation-image
2424

2525
PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME := docker/cnab-app-base:$(TAG)
2626

@@ -39,6 +39,8 @@ 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)
43+
@$(call chmod,+x,bin/$(BIN_NAME)-linux-arm)
4244
@$(call chmod,+x,bin/$(BIN_NAME)-darwin)
4345
@$(call chmod,+x,bin/$(BIN_NAME)-windows.exe)
4446

@@ -60,6 +62,8 @@ e2e-cross: create_bin
6062
tars:
6163
tar --transform='flags=r;s|$(BIN_NAME)-linux|$(BIN_NAME)-plugin-linux|' -czf bin/$(BIN_NAME)-linux.tar.gz -C bin $(BIN_NAME)-linux
6264
tar czf bin/$(BIN_NAME)-e2e-linux.tar.gz -C bin $(BIN_NAME)-e2e-linux
65+
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
66+
tar --transform='flags=r;s|$(BIN_NAME)-linux-arm|$(BIN_NAME)-plugin-linux-arm|' -czf bin/$(BIN_NAME)-linux-arm.tar.gz -C bin $(BIN_NAME)-linux-arm
6367
tar --transform='flags=r;s|$(BIN_NAME)-darwin|$(BIN_NAME)-plugin-darwin|' -czf bin/$(BIN_NAME)-darwin.tar.gz -C bin $(BIN_NAME)-darwin
6468
tar czf bin/$(BIN_NAME)-e2e-darwin.tar.gz -C bin $(BIN_NAME)-e2e-darwin
6569
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
@@ -119,21 +123,43 @@ specification/bindata.go: specification/schemas/*.json build_dev_image
119123
schemas: specification/bindata.go ## generate specification/bindata.go from json schemas
120124

121125
invocation-image:
122-
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) .
126+
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) -t $(CNAB_BASE_INVOCATION_IMAGE_NAME)-amd64 --platform=amd64 .
127+
128+
invocation-image-arm64:
129+
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 --platform=arm64 .
130+
131+
invocation-image-arm:
132+
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm --platform=arm .
133+
134+
invocation-image-cross: invocation-image invocation-image-arm64 invocation-image-arm
123135

124136
save-invocation-image-tag:
125137
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME) docker/cnab-app-base:$(INVOCATION_IMAGE_TAG)
126138
docker save docker/cnab-app-base:$(INVOCATION_IMAGE_TAG) -o _build/$(OUTPUT)
127139

128-
save-invocation-image: invocation-image
140+
save-invocation-image:
129141
@$(call mkdir,_build)
130-
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME) -o $(CNAB_BASE_INVOCATION_IMAGE_PATH)
142+
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME) -o $(CNAB_BASE_INVOCATION_IMAGE_PATH).tar
143+
144+
save-invocation-image-cross: save-invocation-image
145+
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 -o $(CNAB_BASE_INVOCATION_IMAGE_PATH)-arm64.tar
146+
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm -o $(CNAB_BASE_INVOCATION_IMAGE_PATH)-arm.tar
131147

132148
push-invocation-image:
149+
# tag and push linux/amd64
133150
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)
134151
docker push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)
152+
# tag and push linux/arm64
153+
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64
154+
docker push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64
155+
# tag and push linux/armhf
156+
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm
157+
docker push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm
158+
# create and push manifest list
159+
docker manifest create $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm
160+
docker manifest push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)
135161

136162
help: ## this help
137163
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
138164

139-
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage coverage-run coverage-results shell build_dev_image tars vendor check-vendor schemas help invocation-image save-invocation-image save-invocation-image-tag push-invocation-image
165+
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage coverage-run coverage-results shell build_dev_image tars vendor check-vendor schemas help invocation-image invocation-image-arm invocation-image-arm64 invocation-image-cross save-invocation-image save-invocation-image-tag push-invocation-image

e2e/compatibility_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ func TestBackwardsCompatibilityV1(t *testing.T) {
138138
output = info.execCmd("/usr/bin/wget", "-O", "-", url)
139139
return strings.Contains(output, `Hi there, I love Docker!`), nil
140140
})
141-
assert.NilError(t, err)
141+
output = ""
142+
if err != nil {
143+
output = info.dockerCmd("stack", "ps", appName)
144+
}
145+
assert.NilError(t, err, output)
142146
}
143147

144148
// Check status on install

0 commit comments

Comments
 (0)