build image for arm architectures

This commit is contained in:
Frederik Ring 2021-07-01 08:18:04 +02:00
parent 5be3c36040
commit 23c287bfc7
4 changed files with 47 additions and 19 deletions

View File

@ -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.*/

View File

@ -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

View File

@ -1,5 +0,0 @@
DOCKER_TAG ?= local
.PHONY: build
build:
@docker build -t offen/docker-volume-backup:$(DOCKER_TAG) .

View File

@ -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.