diff options
author | Dan Rice <dan@dnrce.com> | 2020-01-20 20:56:00 +0300 |
---|---|---|
committer | Dan Rice <dan@dnrce.com> | 2020-01-20 21:17:23 +0300 |
commit | b6720241b32e8c96c4ac2d0b3378b041ea6383b9 (patch) | |
tree | b73bc7fda0a720f2c4195fe774251c9cacf1a6db /Installer | |
parent | 85f2431e7d3f6ff4fe09594c798a8781c2114711 (diff) |
Build true multi-arch Docker images
Diffstat (limited to 'Installer')
-rw-r--r-- | Installer/Docker/README.md | 8 | ||||
-rwxr-xr-x | Installer/Docker/build-images.sh | 49 | ||||
-rw-r--r-- | Installer/Docker/context/Dockerfile | 3 |
3 files changed, 25 insertions, 35 deletions
diff --git a/Installer/Docker/README.md b/Installer/Docker/README.md index 6060d101c..bdb5f1d8e 100644 --- a/Installer/Docker/README.md +++ b/Installer/Docker/README.md @@ -13,12 +13,10 @@ Duplicati is licensed under LGPL and available for Windows, OSX and Linux (.NET * `latest` - an alias for `beta` * specific versions like `2.0.2.1_beta_2017-08-01` -Images for the following OS/architecture combinations are available: +Images for the following OS/architecture combinations are available using Docker's multi-arch support: - * `linux-amd64` - * `linux-arm32v7` - 32-bit ARMv7 devices like the Raspberry Pi 2 - -The default architecture is `linux-amd64`. To pull an image for another architecture, prepend the architecture string to the image tag, e.g. `linux-arm32v7-beta`. + * `linux/amd64` + * `linux/arm/v7` - 32-bit ARMv7 devices like the Raspberry Pi 2 ## How to use this image diff --git a/Installer/Docker/build-images.sh b/Installer/Docker/build-images.sh index 1aace28dc..a5123e5f9 100755 --- a/Installer/Docker/build-images.sh +++ b/Installer/Docker/build-images.sh @@ -5,10 +5,10 @@ if [ ! -f "$1" ]; then exit fi -ARCHITECTURES="amd64 arm32v7" -DEFAULT_ARCHITECTURE=amd64 +PLATFORMS="linux/amd64,linux/arm/v7" DEFAULT_CHANNEL=beta REPOSITORY=duplicati/duplicati +PUSH_TO_REGISTRY=${PUSH_TO_REGISTRY:-true} ARCHIVE_NAME=$(basename -s .zip $1) VERSION=$(echo "${ARCHIVE_NAME}" | cut -d "-" -f 2-) @@ -40,34 +40,27 @@ do done done -for arch in ${ARCHITECTURES}; do - tags="linux-${arch}-${VERSION} linux-${arch}-${CHANNEL}" - if [ ${CHANNEL} = ${DEFAULT_CHANNEL} ]; then - tags="linux-${arch}-latest ${tags}" - fi - if [ ${arch} = ${DEFAULT_ARCHITECTURE} ]; then - tags="${VERSION} ${CHANNEL} ${tags}" - fi - if [ ${CHANNEL} = ${DEFAULT_CHANNEL} -a ${arch} = ${DEFAULT_ARCHITECTURE} ]; then - tags="latest ${tags}" - fi +tags="${VERSION} ${CHANNEL}" +if [ ${CHANNEL} = ${DEFAULT_CHANNEL} ]; then + tags="latest ${tags}" +fi - args="" - for tag in ${tags}; do - args="-t ${REPOSITORY}:${tag} ${args}" - done +args="" +for tag in ${tags}; do + args="-t ${REPOSITORY}:${tag} ${args}" +done - docker build \ - ${args} \ - --build-arg ARCH=${arch}/ \ - --build-arg VERSION=${VERSION} \ - --build-arg CHANNEL=${CHANNEL} \ - --file context/Dockerfile \ - . +docker buildx create --use --name duplicati-multiarch - for tag in ${tags}; do - docker push ${REPOSITORY}:${tag} - done -done +docker buildx build \ + ${args} \ + --platform ${PLATFORMS} \ + --build-arg VERSION=${VERSION} \ + --build-arg CHANNEL=${CHANNEL} \ + --file context/Dockerfile \ + --output type=image,push=${PUSH_TO_REGISTRY} \ + . + +docker buildx rm duplicati-multiarch rm -rf "${DIRNAME}" diff --git a/Installer/Docker/context/Dockerfile b/Installer/Docker/context/Dockerfile index d1ca6aa57..c93e0d54a 100644 --- a/Installer/Docker/context/Dockerfile +++ b/Installer/Docker/context/Dockerfile @@ -1,5 +1,4 @@ -ARG ARCH= -FROM ${ARCH}mono:5-slim +FROM --platform=$TARGETPLATFORM mono:5-slim RUN apt-get update && \ apt-get install -y --no-install-recommends \ |