From eb51631f3312593a9f0ac449cf7f1145836f43a6 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 2 Jul 2019 14:09:42 +0200 Subject: [PATCH] Build ARM container images (#242) It also updates the Circle CI configuration to use the Prometheus orb. Signed-off-by: Simon Pasquier --- .circleci/config.yml | 85 ++++++-------------------------------------- .dockerignore | 2 ++ Dockerfile | 8 +++-- Makefile | 3 ++ 4 files changed, 21 insertions(+), 77 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ec030f..d59b76e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,9 @@ --- version: 2.1 +orbs: + prometheus: prometheus/prometheus@0.1.0 + executors: # Whenever the Go version is updated here, .travis.yml and .promu.yml # should also be updated. @@ -13,80 +16,11 @@ jobs: executor: golang steps: - - checkout - - run: make promu + - prometheus/setup_environment - run: make - run: git diff --exit-code - - store_artifacts: - path: statsd_exporter - destination: /build/statsd_exporter - - run: rm -v statsd_exporter - - 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/statsd_exporter statsd_exporter - - 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/statsd_exporter statsd_exporter - - 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 + - prometheus/store_artifact: + file: statsd_exporter workflows: version: 2 @@ -96,11 +30,12 @@ workflows: filters: tags: only: /.*/ - - build: + - prometheus/build: + name: build filters: tags: only: /.*/ - - docker_hub_master: + - prometheus/publish_master: context: org-context requires: - test @@ -108,7 +43,7 @@ workflows: filters: branches: only: master - - docker_hub_release_tags: + - prometheus/publish_release: context: org-context requires: - test diff --git a/.dockerignore b/.dockerignore index 1694cb0..86ab6ab 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ .tarballs/ !.build/linux-amd64 +!.build/linux-armv7 +!.build/linux-arm64 diff --git a/Dockerfile b/Dockerfile index 5875bac..f4a1910 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ -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 statsd_exporter /bin/statsd_exporter +ARG ARCH="amd64" +ARG OS="linux" +COPY .build/${OS}-${ARCH}/statsd_exporter /bin/statsd_exporter USER nobody EXPOSE 9102 9125 9125/udp diff --git a/Makefile b/Makefile index 39ff3f4..62f00e2 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 =