Skip to content

Commit

Permalink
Build ARM container images (#80)
Browse files Browse the repository at this point in the history
It also updates the Circle CI configuration to use the Prometheus orb.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
  • Loading branch information
simonpasquier committed Jul 12, 2019
1 parent a3efd52 commit ce323be
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 75 deletions.
84 changes: 10 additions & 74 deletions .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.
Expand All @@ -13,79 +16,11 @@ jobs:
executor: golang

steps:
- checkout
- run: make promu
- prometheus/setup_environment
- run: make
- prometheus/store_artifact:
file: collectd_exporter
- run: git diff --exit-code
- store_artifacts:
path: collectd_exporter
destination: /build/collectd_exporter
- run: rm -v collectd_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/collectd_exporter collectd_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
- 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}
- 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/collectd_exporter collectd_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: |
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"

workflows:
version: 2
Expand All @@ -95,19 +30,20 @@ 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
Expand Down
2 changes: 2 additions & 0 deletions .dockerignore
Expand Up @@ -2,3 +2,5 @@
.tarballs/

!.build/linux-amd64/
!.build/linux-armv7
!.build/linux-arm64
6 changes: 5 additions & 1 deletion Dockerfile
@@ -1,7 +1,11 @@
ARG ARCH="amd64"
ARG OS="linux"
FROM quay.io/prometheus/busybox:latest
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>

COPY collectd_exporter /bin/collectd_exporter
ARG ARCH="amd64"
ARG OS="linux"
COPY .build/${OS}-${ARCH}/collectd_exporter /bin/collectd_exporter

EXPOSE 9103
ENTRYPOINT [ "/bin/collectd_exporter" ]
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -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

DOCKER_IMAGE_NAME ?= collectd-exporter

0 comments on commit ce323be

Please sign in to comment.