Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Push cnab-app-base image as a multi-arch image with linux-amd64 and l…
Browse files Browse the repository at this point in the history
…inux-arm64 platforms.

Signed-off-by: Silvin Lubecki <[email protected]>
  • Loading branch information
silvin-lubecki committed Dec 9, 2019
1 parent 8d02116 commit 8ec5d25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
dir('src/github.com/docker/app') {
checkout scm
ansiColor('xterm') {
sh 'make -f docker.Makefile save-invocation-image'
sh 'make -f docker.Makefile invocation-image save-invocation-image'
sh 'make -f docker.Makefile INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar save-invocation-image-tag'
}
dir('_build') {
Expand Down
9 changes: 7 additions & 2 deletions Jenkinsfile.baguette
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,21 @@ pipeline {
dir('src/github.com/docker/app') {
checkout scm
ansiColor('xterm') {
sh 'make -f docker.Makefile save-invocation-image'
sh 'make -f docker.Makefile invocation-image-cross save-invocation-image-cross'
sh 'make -f docker.Makefile save-invocation-image-tag INVOCATION_IMAGE_TAG=$TAG-coverage OUTPUT=coverage-invocation-image.tar'
}
dir('_build') {
stash name: 'invocation-image', includes: 'invocation-image.tar'
stash name: 'invocation-image-arm64', includes: 'invocation-image-arm64.tar'
stash name: 'coverage-invocation-image', includes: 'coverage-invocation-image.tar'
archiveArtifacts 'invocation-image.tar'
archiveArtifacts 'invocation-image*.tar'
}
}
}
post {
always {
sh 'docker rmi docker/cnab-app-base:$TAG'
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
sh 'docker rmi docker/cnab-app-base:$TAG-coverage'
deleteDir()
}
Expand Down Expand Up @@ -250,6 +252,8 @@ pipeline {
dir('_build') {
unstash "invocation-image"
sh 'docker load -i invocation-image.tar'
unstash "invocation-image-arm64"
sh 'docker load -i invocation-image-arm64.tar'
}
ansiColor('xterm') {
sh 'make -f docker.Makefile push-invocation-image'
Expand All @@ -264,6 +268,7 @@ pipeline {
post {
always {
sh 'docker rmi docker/cnab-app-base:$TAG'
sh 'docker rmi docker/cnab-app-base:$TAG-arm64'
deleteDir()
}
}
Expand Down
25 changes: 20 additions & 5 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PKG_PATH := /go/src/$(PKG_NAME)


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

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

Expand Down Expand Up @@ -121,21 +121,36 @@ specification/bindata.go: specification/schemas/*.json build_dev_image
schemas: specification/bindata.go ## generate specification/bindata.go from json schemas

invocation-image:
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME) .
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 .

invocation-image-arm64:
docker build -f Dockerfile.invocation-image $(BUILD_ARGS) --target=invocation -t $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 --platform=arm64 .

invocation-image-cross: invocation-image invocation-image-arm64

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

save-invocation-image: invocation-image
save-invocation-image:
@$(call mkdir,_build)
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME) -o $(CNAB_BASE_INVOCATION_IMAGE_PATH)
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME) -o $(CNAB_BASE_INVOCATION_IMAGE_PATH).tar

save-invocation-image-cross: save-invocation-image
docker save $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 -o $(CNAB_BASE_INVOCATION_IMAGE_PATH)-arm64.tar

push-invocation-image:
# tag and push linux/amd64
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)
docker push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)
# tag and push linux/arm64
docker tag $(CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64 $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64
docker push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64
# create and push manifest list
docker manifest create $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME) $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)-arm64
docker manifest push $(PUSH_CNAB_BASE_INVOCATION_IMAGE_NAME)

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

.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
.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-arm64 invocation-image-cross save-invocation-image save-invocation-image-tag push-invocation-image

0 comments on commit 8ec5d25

Please sign in to comment.