From 23c287bfc7abaf5a3f7a4c56d20b1ea357373aa3 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Thu, 1 Jul 2021 08:18:04 +0200 Subject: [PATCH] build image for arm architectures --- .circleci/config.yml | 56 ++++++++++++++++++++++++++++++++++---------- Dockerfile | 4 +++- Makefile | 5 ---- README.md | 1 + 4 files changed, 47 insertions(+), 19 deletions(-) delete mode 100644 Makefile diff --git a/.circleci/config.yml b/.circleci/config.yml index 7418ed1..adb36bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,40 +1,70 @@ version: 2.1 jobs: - build: + canary: docker: - image: cimg/base:2020.06 working_directory: ~/docker-volume-backup steps: - checkout - - setup_remote_docker + - setup_remote_docker: + version: 20.10.6 - run: name: Build - command: make build - - run: - name: Check if image needs to be pushed command: | - if [[ -z "$CIRCLE_TAG" ]]; then - echo "Not a git tag, nothing to do ..." - circleci-agent step halt + docker build . -t offen/docker-volume-backup:canary + - run: + name: Create container from image + command: | + docker run -d offen/docker-volume-backup:canary + echo "Sleeping for 30s before checking if container is still running." + sleep 30 + count=$(docker ps -q | wc -l) + if [[ $count != "1" ]]; then + echo "Expected one container to be running, found $count." + exit 1 fi + docker stop $(docker ps -q) + + build: + docker: + - image: cimg/base:2020.06 + environment: + DOCKER_BUILDKIT: '1' + DOCKER_CLI_EXPERIMENTAL: enabled + working_directory: ~/docker-volume-backup + steps: + - checkout + - setup_remote_docker: + version: 20.10.6 - docker/install-docker-credential-helper - docker/configure-docker-credentials-store - run: name: Push to Docker Hub command: | echo "$DOCKER_ACCESSTOKEN" | docker login --username offen --password-stdin - docker tag offen/docker-volume-backup:local offen/docker-volume-backup:$CIRCLE_TAG - docker tag offen/docker-volume-backup:local offen/docker-volume-backup:latest - docker push offen/docker-volume-backup:$CIRCLE_TAG - docker push offen/docker-volume-backup:latest + # This is required for building ARM: https://gitlab.alpinelinux.org/alpine/aports/-/issues/12406 + docker run --rm --privileged linuxkit/binfmt:v0.8 + docker context create docker-volume-backup + docker buildx create docker-volume-backup --name docker-volume-backup --use + docker buildx inspect --bootstrap + docker buildx build --platform linux/arm64,linux/amd64 \ + -t offen/docker-volume-backup:$CIRCLE_TAG \ + -t offen/docker-volume-backup:latest \ + . --push workflows: version: 2 - deploy: + docker_image: jobs: + - canary: + filters: + tags: + ignore: /^v.*/ - build: filters: + branches: + ignore: /.*/ tags: only: /^v.*/ diff --git a/Dockerfile b/Dockerfile index f3a949d..4223f32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,11 @@ FROM alpine:3.14 WORKDIR /root RUN apk add --update ca-certificates docker openrc gnupg +RUN update-ca-certificates RUN rc-update add docker boot -RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc && \ +ARG TARGETARCH=amd64 +RUN wget https://dl.min.io/client/mc/release/linux-$TARGETARCH/mc && \ chmod +x mc && \ mv mc /usr/bin/mc diff --git a/Makefile b/Makefile deleted file mode 100644 index a00b636..0000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -DOCKER_TAG ?= local - -.PHONY: build -build: - @docker build -t offen/docker-volume-backup:$(DOCKER_TAG) . diff --git a/README.md b/README.md index 1ee116c..d6d1c5e 100644 --- a/README.md +++ b/README.md @@ -114,3 +114,4 @@ This image is heavily inspired by the `futurice/docker-volume-backup`. We decide - This image makes use of the MinIO client `mc` instead of the full blown AWS CLI for uploading backups. - The original image proposed to handle backup rotation through AWS S3 lifecycle policies. This image adds the option to rotate old backups through the same script so this functionality can also be offered for non-AWS storage backends like MinIO. - InfluxDB specific functionality was removed. +- `arm64` Architecture is supported.