From b60779e52780c7de9d58ea8b8bef2c04ff655936 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Thu, 18 Jul 2019 12:19:44 +0200 Subject: [PATCH] Build ARM container images It also updates the Circle CI configuration to use the Prometheus orb. Signed-off-by: Simon Pasquier --- .circleci/config.yml | 97 ++++++++------------------------------------ Dockerfile | 6 ++- Makefile | 3 ++ 3 files changed, 24 insertions(+), 82 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a0afa598..058201e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,89 +1,23 @@ --- version: 2.1 -executors: - # Whenever the Go version is updated here, .travis.yml and .promu.yml - # should also be updated. - golang: - docker: - - image: circleci/golang:1.12 - working_directory: /go/src/github.com/prometheus/prom2json +orbs: + prometheus: prometheus/prometheus@0.1.0 jobs: test: - executor: golang + # Whenever the Go version is updated here, .travis.yml and .promu.yml + # should also be updated. + golang: + docker: + - image: circleci/golang:1.12 + working_directory: /go/src/github.com/prometheus/prom2json steps: - - checkout - - run: make promu + - prometheus/setup_environment - run: make - - run: git diff --exit-code - - store_artifacts: - path: prom2json - destination: /build/prom2json - - run: rm -v prom2json - - build: - machine: true - - steps: - - checkout - - run: make promu - - run: promu crossbuild -v - - persist_to_workspace: - root: . - paths: - - .build - - store_artifacts: - path: .build - destination: /build - - docker_hub_master: - executor: golang - - steps: - - checkout - - setup_remote_docker - - attach_workspace: - at: . - - run: ln -s .build/linux-amd64/prom2json prom2json - - run: make docker - - run: make docker DOCKER_REPO=quay.io/prometheus - - run: docker images - - run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD - - run: docker login -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io - - run: make docker-publish - - run: make docker-publish DOCKER_REPO=quay.io/prometheus - - docker_hub_release_tags: - executor: golang - - steps: - - checkout - - setup_remote_docker - - attach_workspace: - at: . - - run: make promu - - run: promu crossbuild tarballs - - run: promu checksum .tarballs - - run: promu release .tarballs - - store_artifacts: - path: .tarballs - destination: releases - - run: ln -s .build/linux-amd64/prom2json prom2json - - 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: | - 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 - fi - - run: make docker-publish DOCKER_IMAGE_TAG="$CIRCLE_TAG" - - run: make docker-publish DOCKER_REPO=quay.io/prometheus DOCKER_IMAGE_TAG="$CIRCLE_TAG" + - prometheus/store_artifact: + file: prom2json workflows: version: 2 @@ -93,18 +27,21 @@ workflows: filters: tags: only: /.*/ - - build: + - prometheus/build: + name: build filters: tags: only: /.*/ - - docker_hub_master: + - prometheus/publish_master: + context: org-context requires: - test - build filters: branches: only: master - - docker_hub_release_tags: + - prometheus/publish_release: + context: org-context requires: - test - build diff --git a/Dockerfile b/Dockerfile index 653be6f9..67d0bc01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ -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 prom2json /bin/prom2json +COPY .build/${OS}-${ARCH}/prom2json /bin/prom2json USER nobody ENTRYPOINT [ "/bin/prom2json" ] diff --git a/Makefile b/Makefile index 214b04a3..935ac437 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 =