From 8dfd829fefc4e3124f717e6d969549945ee18320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Mon, 15 Apr 2019 14:27:00 +0200 Subject: [PATCH] Docker images for ARM32v7 and ARM64v8 (#5031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build and publish ARM32v7 and ARM64v8 docker images. Signed-off-by: Johannes Würbach --- .circleci/config.yml | 24 ++++++++++++++++-------- .dockerignore | 2 ++ Dockerfile | 10 +++++++--- Makefile | 3 +++ Makefile.common | 39 ++++++++++++++++++++++++++++----------- 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c9af7c5bf..2bbf7cf49 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,11 +53,11 @@ jobs: steps: - checkout - - setup_remote_docker + - setup_remote_docker: + version: 18.06.0-ce + - run: docker run --privileged linuxkit/binfmt:v0.6 - attach_workspace: at: . - - run: ln -s .build/linux-amd64/prometheus prometheus - - run: ln -s .build/linux-amd64/promtool promtool - run: make docker - run: make docker DOCKER_REPO=quay.io/prometheus - run: docker images @@ -65,13 +65,17 @@ jobs: - run: docker login -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io - run: make docker-publish - run: make docker-publish DOCKER_REPO=quay.io/prometheus + - run: make docker-manifest + - run: make docker-manifest DOCKER_REPO=quay.io/prometheus docker_hub_release_tags: executor: golang steps: - checkout - - setup_remote_docker + - setup_remote_docker: + version: 18.06.0-ce + - run: docker run --privileged linuxkit/binfmt:v0.6 - run: mkdir -v -p ${HOME}/bin - run: curl -L 'https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C ${HOME}/bin - run: echo 'export PATH=${HOME}/bin:${PATH}' >> ${BASH_ENV} @@ -84,19 +88,23 @@ jobs: - store_artifacts: path: .tarballs destination: releases - - run: ln -s .build/linux-amd64/prometheus prometheus - - run: ln -s .build/linux-amd64/promtool promtool - run: make docker DOCKER_IMAGE_TAG=$CIRCLE_TAG - run: make docker DOCKER_IMAGE_TAG=$CIRCLE_TAG DOCKER_REPO=quay.io/prometheus - run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - run: docker login -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io + - run: make docker-publish DOCKER_IMAGE_TAG="$CIRCLE_TAG" + - run: make docker-publish DOCKER_IMAGE_TAG="$CIRCLE_TAG" DOCKER_REPO=quay.io/prometheus + - run: make docker-manifest DOCKER_IMAGE_TAG="$CIRCLE_TAG" + - run: make docker-manifest DOCKER_IMAGE_TAG="$CIRCLE_TAG" DOCKER_REPO=quay.io/prometheus - run: | if [[ "$CIRCLE_TAG" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then make docker-tag-latest DOCKER_IMAGE_TAG="$CIRCLE_TAG" make docker-tag-latest DOCKER_IMAGE_TAG="$CIRCLE_TAG" DOCKER_REPO=quay.io/prometheus + make docker-publish DOCKER_IMAGE_TAG="latest" + make docker-publish DOCKER_IMAGE_TAG="latest" DOCKER_REPO=quay.io/prometheus + make docker-manifest DOCKER_IMAGE_TAG="latest" + make docker-manifest DOCKER_IMAGE_TAG="latest" DOCKER_REPO=quay.io/prometheus fi - - run: make docker-publish - - run: make docker-publish DOCKER_REPO=quay.io/prometheus makefile_sync: executor: golang diff --git a/.dockerignore b/.dockerignore index a4d092b22..07a4d4f57 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,5 @@ data/ .tarballs/ !.build/linux-amd64/ +!.build/linux-armv7/ +!.build/linux-arm64/ diff --git a/Dockerfile b/Dockerfile index 00700591f..e42b18ef6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ -FROM quay.io/prometheus/busybox:latest +ARG ARCH="amd64" +ARG OS="linux" +FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest LABEL maintainer="The Prometheus Authors " -COPY prometheus /bin/prometheus -COPY promtool /bin/promtool +ARG ARCH="amd64" +ARG OS="linux" +COPY .build/${OS}-${ARCH}/prometheus /bin/prometheus +COPY .build/${OS}-${ARCH}/promtool /bin/promtool COPY documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml COPY console_libraries/ /usr/share/prometheus/console_libraries/ COPY consoles/ /usr/share/prometheus/consoles/ diff --git a/Makefile b/Makefile index 21d093016..ae0d3d16f 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Needs to be defined before including Makefile.common to auto-generate targets +DOCKER_ARCHS ?= amd64 armv7 arm64 + include Makefile.common STATICCHECK_IGNORE = \ diff --git a/Makefile.common b/Makefile.common index ed29aa822..873964fb4 100644 --- a/Makefile.common +++ b/Makefile.common @@ -88,6 +88,12 @@ BIN_DIR ?= $(shell pwd) DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) DOCKER_REPO ?= prom +DOCKER_ARCHS ?= amd64 + +BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS)) +PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS)) +TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS)) + ifeq ($(GOHOSTARCH),amd64) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows)) # Only supported on amd64 @@ -197,17 +203,28 @@ common-tarball: promu @echo ">> building release tarball" $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) -.PHONY: common-docker -common-docker: - docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . - -.PHONY: common-docker-publish -common-docker-publish: - docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)" - -.PHONY: common-docker-tag-latest -common-docker-tag-latest: - docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):latest" +.PHONY: common-docker $(BUILD_DOCKER_ARCHS) +common-docker: $(BUILD_DOCKER_ARCHS) +$(BUILD_DOCKER_ARCHS): common-docker-%: + docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \ + --build-arg ARCH="$*" \ + --build-arg OS="linux" \ + . + +.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS) +common-docker-publish: $(PUBLISH_DOCKER_ARCHS) +$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%: + docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" + +.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS) +common-docker-tag-latest: $(TAG_DOCKER_ARCHS) +$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%: + docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest" + +.PHONY: common-docker-manifest +common-docker-manifest: + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG)) + DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .PHONY: promu promu: $(PROMU)