diff --git a/Dockerfile b/Dockerfile index 610d897..3a850d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM ubuntu:bionic -MAINTAINER ViViDboarder +ARG REPO=library +FROM ${REPO}/ubuntu:bionic +LABEL maintainer="ViViDboarder " RUN apt-get update \ && apt-get install -y --no-install-recommends \ diff --git a/Makefile b/Makefile index 7215c4b..2536d52 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build-x86: .PHONY: build-arm build-arm: - docker build -f ./Dockerfile -t $(DOCKER_TAG) . + docker build --build-arg REPO=arm32v7 -f ./Dockerfile -t $(DOCKER_TAG)-arm32v7 . .PHONY: build-all build-all: build-x86 build-arm diff --git a/hooks/build b/hooks/build new file mode 100755 index 0000000..5fe53b1 --- /dev/null +++ b/hooks/build @@ -0,0 +1,38 @@ +#!/bin/bash +set -ex + +# Extract arch repo from a docker tag suffix +REPO="" +case "$DOCKER_TAG" in + *amd64) + REPO="library" + ;; + *arm32v5) + REPO="arm32v5" + ;; + *arm32v6) + REPO="arm32v6" + ;; + *arm32v7) + REPO="arm32v7" + ;; + *arm64v8) + REPO="arm64v8" + ;; + *i386) + REPO="i386" + ;; + *ppc64le) + REPO="ppc64le" + ;; + *s390x) + REPO="s390x" + ;; + *) + REPO="library" + ;; +esac + +docker build \ + --build-arg REPO="$REPO" \ + --tag "$IMAGE_NAME" . diff --git a/hooks/post_push b/hooks/post_push new file mode 100755 index 0000000..a4e3041 --- /dev/null +++ b/hooks/post_push @@ -0,0 +1,9 @@ +#!/bin/bash + +# Use manifest-tool to create the manifest, given the experimental +# "docker manifest" command isn't available yet on Docker Hub. + +curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 +chmod +x manifest-tool + +./manifest-tool push from-spec multi-arch-manifest.yml diff --git a/hooks/pre_build b/hooks/pre_build new file mode 100755 index 0000000..cc124f1 --- /dev/null +++ b/hooks/pre_build @@ -0,0 +1,39 @@ +#!/bin/bash +set -ex + +REPO="" +case "$DOCKER_TAG" in + *amd64) + REPO="library" + ;; + *arm32v5) + REPO="arm32v5" + ;; + *arm32v6) + REPO="arm32v6" + ;; + *arm32v7) + REPO="arm32v7" + ;; + *arm64v8) + REPO="arm64v8" + ;; + *i386) + REPO="i386" + ;; + *ppc64le) + REPO="ppc64le" + ;; + *s390x) + REPO="s390x" + ;; + *) + REPO="library" + ;; +esac + + +[ "${REPO}" != "library" ] && \ + { echo 'qemu-user-static: Registration not required for current arch'; exit 0; } + +docker run --rm --privileged multiarch/qemu-user-static:register --reset diff --git a/multi-arch-manifest.yml b/multi-arch-manifest.yml new file mode 100644 index 0000000..13ef835 --- /dev/null +++ b/multi-arch-manifest.yml @@ -0,0 +1,17 @@ +--- +image: vividboarder/docker-restic-cron:latest +manifests: + - image: vividboarder/docker-restic-cron:amd64 + platform: + architecture: amd64 + os: linux + - image: vividboarder/docker-restic-cron:arm32v7 + platform: + architecture: arm + os: linux + variant: v7 + - image: vividboarder/docker-restic-cron:arm64v8 + platform: + architecture: arm64 + os: linux + variant: v8