Add multi-arch builds

This commit is contained in:
ViViDboarder 2020-02-10 17:49:39 -08:00
parent fd148ac502
commit 69e113ff3f
6 changed files with 107 additions and 3 deletions

View File

@ -1,5 +1,6 @@
FROM ubuntu:bionic ARG REPO=library
MAINTAINER ViViDboarder <vividboarder@gmail.com> FROM ${REPO}/ubuntu:bionic
LABEL maintainer="ViViDboarder <vividboarder@gmail.com>"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \

View File

@ -12,7 +12,7 @@ build-x86:
.PHONY: build-arm .PHONY: build-arm
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 .PHONY: build-all
build-all: build-x86 build-arm build-all: build-x86 build-arm

38
hooks/build Executable file
View File

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

9
hooks/post_push Executable file
View File

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

39
hooks/pre_build Executable file
View File

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

17
multi-arch-manifest.yml Normal file
View File

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