Merge pull request #5 from offen/multiarch

Build image for arm architectures
This commit is contained in:
Frederik Ring 2021-07-01 14:22:54 +02:00 committed by GitHub
commit c33ebc0c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 19 deletions

View File

@ -1,40 +1,70 @@
version: 2.1 version: 2.1
jobs: jobs:
build: canary:
docker: docker:
- image: cimg/base:2020.06 - image: cimg/base:2020.06
working_directory: ~/docker-volume-backup working_directory: ~/docker-volume-backup
steps: steps:
- checkout - checkout
- setup_remote_docker - setup_remote_docker:
version: 20.10.6
- run: - run:
name: Build name: Build
command: make build
- run:
name: Check if image needs to be pushed
command: | command: |
if [[ -z "$CIRCLE_TAG" ]]; then docker build . -t offen/docker-volume-backup:canary
echo "Not a git tag, nothing to do ..." - run:
circleci-agent step halt 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 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/install-docker-credential-helper
- docker/configure-docker-credentials-store - docker/configure-docker-credentials-store
- run: - run:
name: Push to Docker Hub name: Push to Docker Hub
command: | command: |
echo "$DOCKER_ACCESSTOKEN" | docker login --username offen --password-stdin echo "$DOCKER_ACCESSTOKEN" | docker login --username offen --password-stdin
docker tag offen/docker-volume-backup:local offen/docker-volume-backup:$CIRCLE_TAG # This is required for building ARM: https://gitlab.alpinelinux.org/alpine/aports/-/issues/12406
docker tag offen/docker-volume-backup:local offen/docker-volume-backup:latest docker run --rm --privileged linuxkit/binfmt:v0.8
docker push offen/docker-volume-backup:$CIRCLE_TAG docker context create docker-volume-backup
docker push offen/docker-volume-backup:latest 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: workflows:
version: 2 version: 2
deploy: docker_image:
jobs: jobs:
- canary:
filters:
tags:
ignore: /^v.*/
- build: - build:
filters: filters:
branches:
ignore: /.*/
tags: tags:
only: /^v.*/ only: /^v.*/

View File

@ -6,9 +6,11 @@ FROM alpine:3.14
WORKDIR /root WORKDIR /root
RUN apk add --update ca-certificates docker openrc gnupg RUN apk add --update ca-certificates docker openrc gnupg
RUN update-ca-certificates
RUN rc-update add docker boot 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 && \ chmod +x mc && \
mv mc /usr/bin/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. - 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. - 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. - InfluxDB specific functionality was removed.
- `arm64` Architecture is supported.