From 6faa52bdd4a2bc02ae151d97a18a89ddad062a6b Mon Sep 17 00:00:00 2001 From: John Date: Wed, 10 Nov 2021 20:16:26 +0100 Subject: [PATCH] switch to using docker buildx with multi-arch --- contrib/docker/Dockerfile | 28 ++++++--- contrib/docker/Dockerfile.arm32v5 | 44 --------------- contrib/docker/Dockerfile.arm32v7 | 44 --------------- contrib/docker/Dockerfile.arm64v8 | 44 --------------- contrib/docker/Dockerfile.i386 | 44 --------------- contrib/docker/Dockerfile.release | 30 ++++++---- contrib/docker/Dockerfile.release.arm32v5 | 44 --------------- contrib/docker/Dockerfile.release.arm32v7 | 44 --------------- contrib/docker/Dockerfile.release.arm64v8 | 44 --------------- contrib/docker/Dockerfile.release.i386 | 44 --------------- contrib/docker/Dockerfile.template | 38 ++++++++----- contrib/docker/README.md | 9 ++- contrib/docker/build.sh | 69 +++++++++++++++++------ contrib/docker/update.sh | 66 +++++++--------------- 14 files changed, 139 insertions(+), 453 deletions(-) delete mode 100644 contrib/docker/Dockerfile.arm32v5 delete mode 100644 contrib/docker/Dockerfile.arm32v7 delete mode 100644 contrib/docker/Dockerfile.arm64v8 delete mode 100644 contrib/docker/Dockerfile.i386 delete mode 100644 contrib/docker/Dockerfile.release.arm32v5 delete mode 100644 contrib/docker/Dockerfile.release.arm32v7 delete mode 100644 contrib/docker/Dockerfile.release.arm64v8 delete mode 100644 contrib/docker/Dockerfile.release.i386 diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index 6a7ba5cc..ddd792ee 100755 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -1,5 +1,6 @@ +ARG BASE_IMAGE -FROM debian:bullseye as build +FROM $BASE_IMAGE as build RUN apt-get update && apt-get install -y \ libmosquitto-dev libstdc++6 libc6 libgcc1 \ @@ -9,16 +10,20 @@ RUN apt-get update && apt-get install -y \ WORKDIR /build -ENV EBUSD_ARCH amd64 -ENV EBUSD_VERSION 21.3 +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION + +ADD . /build +RUN ./make_debian.sh -FROM debian:bullseye-slim +FROM $BASE_IMAGE-slim as image RUN apt-get update && apt-get install -y \ libmosquitto1 libstdc++6 libc6 libgcc1 \ @@ -26,8 +31,13 @@ RUN apt-get update && apt-get install -y \ LABEL maintainer "ebusd@ebusd.eu" -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH amd64 +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION +ARG EBUSD_IMAGE + +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel" @@ -39,6 +49,6 @@ RUN dpkg -i ebusd.deb \ EXPOSE 8888 -COPY docker-entrypoint.sh / +COPY --from=build /build/contrib/docker/docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.arm32v5 b/contrib/docker/Dockerfile.arm32v5 deleted file mode 100644 index 0cc858b7..00000000 --- a/contrib/docker/Dockerfile.arm32v5 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm32v5/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm32v5 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm32v5/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm32v5 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-arm-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.arm32v7 b/contrib/docker/Dockerfile.arm32v7 deleted file mode 100644 index 9ebe456b..00000000 --- a/contrib/docker/Dockerfile.arm32v7 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm32v7/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm32v7 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm32v7/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm32v7 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-arm-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.arm64v8 b/contrib/docker/Dockerfile.arm64v8 deleted file mode 100644 index 3bf92764..00000000 --- a/contrib/docker/Dockerfile.arm64v8 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm64v8/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm64v8 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm64v8/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm64v8 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-aarch64-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.i386 b/contrib/docker/Dockerfile.i386 deleted file mode 100644 index d5ed03ea..00000000 --- a/contrib/docker/Dockerfile.i386 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM i386/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-i386-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH i386 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM i386/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-i386-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH i386 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-i386-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.release b/contrib/docker/Dockerfile.release index 08469954..b76deba5 100644 --- a/contrib/docker/Dockerfile.release +++ b/contrib/docker/Dockerfile.release @@ -1,5 +1,6 @@ +ARG BASE_IMAGE -FROM debian:bullseye as build +FROM $BASE_IMAGE as build RUN apt-get update && apt-get install -y \ libmosquitto-dev libstdc++6 libc6 libgcc1 \ @@ -9,16 +10,20 @@ RUN apt-get update && apt-get install -y \ WORKDIR /build -ENV EBUSD_ARCH amd64 -ENV EBUSD_VERSION 21.3 +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION + +ADD . /build +RUN ./make_debian.sh -FROM debian:bullseye-slim +FROM $BASE_IMAGE-slim as image RUN apt-get update && apt-get install -y \ libmosquitto1 libstdc++6 libc6 libgcc1 \ @@ -26,12 +31,17 @@ RUN apt-get update && apt-get install -y \ LABEL maintainer "ebusd@ebusd.eu" -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH amd64 +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION +ARG EBUSD_IMAGE + +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb +ADD https://github.com/john30/ebusd/releases/download/v${EBUSD_VERSION}/ebusd-${EBUSD_VERSION}_${TARGETARCH}${TARGETVARIANT}-${EBUSD_IMAGE}_mqtt1.deb ebusd.deb RUN dpkg -i ebusd.deb \ && ebusd -V \ @@ -39,6 +49,6 @@ RUN dpkg -i ebusd.deb \ EXPOSE 8888 -COPY docker-entrypoint.sh / +COPY contrib/docker/docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.release.arm32v5 b/contrib/docker/Dockerfile.release.arm32v5 deleted file mode 100644 index 3727b1bc..00000000 --- a/contrib/docker/Dockerfile.release.arm32v5 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm32v5/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm32v5 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm32v5/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm32v5 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-arm-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.release.arm32v7 b/contrib/docker/Dockerfile.release.arm32v7 deleted file mode 100644 index 29498175..00000000 --- a/contrib/docker/Dockerfile.release.arm32v7 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm32v7/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm32v7 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm32v7/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm32v7 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-arm-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.release.arm64v8 b/contrib/docker/Dockerfile.release.arm64v8 deleted file mode 100644 index 5586fdcf..00000000 --- a/contrib/docker/Dockerfile.release.arm64v8 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM arm64v8/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH arm64v8 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM arm64v8/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH arm64v8 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-aarch64-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.release.i386 b/contrib/docker/Dockerfile.release.i386 deleted file mode 100644 index c5fd8eed..00000000 --- a/contrib/docker/Dockerfile.release.i386 +++ /dev/null @@ -1,44 +0,0 @@ -FROM multiarch/qemu-user-static as qemu -FROM i386/debian:bullseye as build -COPY --from=qemu /usr/bin/qemu-i386-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - libmosquitto-dev libstdc++6 libc6 libgcc1 \ - curl \ - autoconf automake g++ make git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /build - -ENV EBUSD_ARCH i386 -ENV EBUSD_VERSION 21.3 - -RUN git clone https://github.com/john30/ebusd.git /build \ - && ./make_debian.sh - - - - -FROM i386/debian:bullseye-slim -COPY --from=qemu /usr/bin/qemu-i386-static /usr/bin/ -RUN apt-get update && apt-get install -y \ - logrotate libmosquitto1 libstdc++6 libc6 libgcc1 \ - && rm -rf /var/lib/apt/lists/* - -LABEL maintainer "ebusd@ebusd.eu" - -ENV EBUSD_VERSION 21.3 -ENV EBUSD_ARCH i386 - -LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" - -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb - -RUN dpkg -i ebusd.deb \ - && ebusd -V \ - && rm -f ebusd.deb /usr/bin/qemu-i386-static - -EXPOSE 8888 - -COPY docker-entrypoint.sh / -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/Dockerfile.template b/contrib/docker/Dockerfile.template index 2ab69a08..2d5f1aee 100644 --- a/contrib/docker/Dockerfile.template +++ b/contrib/docker/Dockerfile.template @@ -1,6 +1,7 @@ -%QEMU_FROM_LINE% -FROM %BASE_IMAGE% as build -%QEMU_FROM_COPY% +ARG BASE_IMAGE + +FROM $BASE_IMAGE as build + RUN apt-get update && apt-get install -y \ libmosquitto-dev libstdc++6 libc6 libgcc1 \ curl \ @@ -9,36 +10,45 @@ RUN apt-get update && apt-get install -y \ WORKDIR /build -ENV EBUSD_ARCH %EBUSD_ARCH% -ENV EBUSD_VERSION %EBUSD_VERSION% +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION -RUN git clone https://github.com/john30/ebusd.git /build \ - && %EBUSD_MAKE% +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION + +ADD . /build +RUN %EBUSD_MAKE% %EBUSD_UPLOAD_LINES% -FROM %BASE_IMAGE%-slim -%QEMU_FROM_COPY% +FROM $BASE_IMAGE-slim as image + RUN apt-get update && apt-get install -y \ libmosquitto1 libstdc++6 libc6 libgcc1 \ && rm -rf /var/lib/apt/lists/* LABEL maintainer "ebusd@ebusd.eu" -ENV EBUSD_VERSION %EBUSD_VERSION% -ENV EBUSD_ARCH %EBUSD_ARCH% +ARG TARGETARCH +ARG TARGETVARIANT +ARG EBUSD_VERSION +ARG EBUSD_IMAGE + +ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT +ENV EBUSD_VERSION $EBUSD_VERSION LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}%EBUSD_VERSION_VARIANT%" -COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb +%EBUSD_COPYDEB% RUN dpkg -i ebusd.deb \ && ebusd -V \ - && rm -f ebusd.deb%EXTRA_RM% + && rm -f ebusd.deb EXPOSE 8888 -COPY docker-entrypoint.sh / +%EBUSD_COPYENTRY% ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["-f", "--scanconfig"] diff --git a/contrib/docker/README.md b/contrib/docker/README.md index e8230073..1d16ad33 100644 --- a/contrib/docker/README.md +++ b/contrib/docker/README.md @@ -2,8 +2,8 @@ ebusd Docker image ================== An [ebusd](https://github.com/john30/ebusd/) Docker image is available on the -[Docker Hub](https://hub.docker.com/r/john30/ebusd/) and comes with the latest German -[configuration files](https://github.com/john30/ebusd-configuration/). +[Docker Hub](https://hub.docker.com/r/john30/ebusd/) and is able to download the latest released German +[configuration files](https://github.com/john30/ebusd-configuration/) from a dedicated webservice. It allows you to run ebusd without actually installing (or even building) it on your system. You might even be able to run it on a non-Linux operating system, which is at least known to @@ -18,12 +18,11 @@ To download the latest release image from the hub, use the following command: The image is able to run on any of the following architectures and the right image will be picked automatically: * amd64 * i386 -* arm32v5 * arm32v7 * arm64v8 -In addition to the default "latest" tag, a development set of images is available with "devel" tag. This is built -automatically with every commit to the git repository. Run the following command to use it: +Due to changes of docker hub policies, the development set of images with "devel" tag are currently not automatically +built with every commit to the git repository. Run the following command to use it: > docker pull john30/ebusd:devel diff --git a/contrib/docker/build.sh b/contrib/docker/build.sh index 94519dc1..f7a32aab 100755 --- a/contrib/docker/build.sh +++ b/contrib/docker/build.sh @@ -1,20 +1,55 @@ #!/bin/bash -archs='amd64 i386 arm32v5 arm32v7 arm64v8' -images='stretch buster bullseye' -UPLOAD_URL='http://'`hostname`'/ebusdreleaseupload.php' +if [[ -z "$1" ]]; then + echo "usage: $0 [release|UPLOADHOST]" + echo " without arguments: build and push devel docker images" + echo " release: build and push release docker images from latest release binaries" + echo " UPLOADHOST: build Debian release packages (with and without MQTT) and upload them to UPLOADHOST" + exit 1 +fi +archs=linux/amd64,linux/386,linux/arm/v7,linux/arm64 +if [[ -z "$1" ]] || [[ "x$1" == "xrelease" ]]; then + UPLOAD_URL= +else + UPLOAD_URL="http://$1/ebusdreleaseupload.php" +fi UPLOAD_CREDENTIALS='anonymous:build' -for image in $images; do - dir=$image - mkdir -p $dir - BASE_IMAGE=debian:$image ./update.sh $dir/ - for arch in $archs; do - if [ "$arch" != "amd64" ]; then - suffix=".$arch" - else - suffix='' - fi - docker build $@ --target build --build-arg "UPLOAD_URL=$UPLOAD_URL" --build-arg "UPLOAD_CREDENTIALS=$UPLOAD_CREDENTIALS" --build-arg "UPLOAD_OS=$image" -f $dir/Dockerfile$suffix . - done - rm -rf $dir -done +version=`cat ../../VERSION` +source='../..' +images='bullseye' +if [[ -z "$1" ]]; then + namesuffix='' + target=image + outputFmt='-o type=docker,type=registry' + tagsuffix=':devel' +elif [[ "x$1" = "xrelease" ]]; then + archs=linux/amd64 + namesuffix='.release' + target=image + outputFmt='-o type=docker,type=registry' + tagsuffix=":v$version" +else + namesuffix='.build' + target=build + images='bullseye buster stretch' + outputFmt=-q + tagsuffix=":v$version-prep" +fi + +for image in $images; do + output=$(echo "$outputFmt"|sed -e "s#%IMAGE%#$image#g") + docker buildx build \ + --target $target \ + --progress pain \ + --platform $archs \ + -f Dockerfile${namesuffix} \ + --build-arg "BASE_IMAGE=debian:$image" \ + --build-arg "EBUSD_VERSION=$version" \ + --build-arg "EBUSD_IMAGE=$image" \ + --build-arg "UPLOAD_URL=$UPLOAD_URL" \ + --build-arg "UPLOAD_CREDENTIALS=$UPLOAD_CREDENTIALS" \ + --build-arg "UPLOAD_OS=$image" \ + -t ebusd$tagsuffix \ + $output \ + $source +done diff --git a/contrib/docker/update.sh b/contrib/docker/update.sh index e78d4830..224ea2af 100755 --- a/contrib/docker/update.sh +++ b/contrib/docker/update.sh @@ -1,63 +1,37 @@ #!/bin/bash -DEFAULT_IMAGE=debian:bullseye -EBUSD_VERSION=`cat ../../VERSION` - -archs='amd64 i386 arm32v5:arm arm32v7:arm arm64v8:aarch64' function replaceTemplate () { - prefix= - suffix= - qemu_from_line= - qemu_from_copy= - extra_rm= - if [ "$arch" != "amd64" ]; then - qemu="${arch##*:}" - arch="${arch%%:*}" - prefix="$arch/" - suffix=".$arch" - qemu_from_line="FROM multiarch/qemu-user-static as qemu" - qemu_from_copy="COPY --from=qemu /usr/bin/qemu-$qemu-static /usr/bin/" - extra_rm=" /usr/bin/qemu-$qemu-static" - fi - file="${dir}Dockerfile${namesuffix}${suffix}" + file="Dockerfile${namesuffix}" sed \ - -e "s#%QEMU_FROM_LINE%#${qemu_from_line}#g" \ - -e "s#%BASE_IMAGE%#${prefix}${BASE_IMAGE:-$DEFAULT_IMAGE}#g" \ - -e "s#%QEMU_FROM_COPY%#${qemu_from_copy}#g" \ -e "s#%EBUSD_MAKE%#${make}#g" \ - -e "s#%EBUSD_VERSION%#${EBUSD_VERSION}#g" \ -e "s#%EBUSD_VERSION_VARIANT%#${version_variant}#g" \ - -e "s#%EBUSD_ARCH%#${arch}#g" \ - -e "s#%EXTRA_RM%#${extra_rm}#g" \ -e "s#%EBUSD_UPLOAD_LINES%#${upload_lines}#g" \ + -e "s#%EBUSD_COPYDEB%#${copydeb}#g" \ + -e "s#%EBUSD_COPYENTRY%#${copyentry}#g" \ Dockerfile.template > "$file" echo "updated $file" } -if [[ -z "$1" ]]; then - # devel updates - version_variant='-devel' - make='./make_debian.sh' - dir='' - upload_line='' - namesuffix='' - for arch in $archs; do - replaceTemplate - done -fi +# devel update +version_variant='-devel' +make='./make_debian.sh' +upload_lines='' +copydeb='COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb' +copyentry='COPY --from=build /build/contrib/docker/docker-entrypoint.sh /' +namesuffix='' +replaceTemplate -# release updates +# release update version_variant='' -dir="$1" +copydeb="ADD https://github.com/john30/ebusd/releases/download/v\${EBUSD_VERSION}/ebusd-\${EBUSD_VERSION}_\${TARGETARCH}\${TARGETVARIANT}-\${EBUSD_IMAGE}_mqtt1.deb ebusd.deb" +copyentry='COPY contrib/docker/docker-entrypoint.sh /' +namesuffix='.release' +replaceTemplate + if [[ -n "$1" ]]; then + # build releases update make='./make_all.sh' upload_lines='ARG UPLOAD_URL\nARG UPLOAD_CREDENTIALS\nARG UPLOAD_OS\nRUN if [ -n "\$UPLOAD_URL" ] \&\& [ -n "\$UPLOAD_CREDENTIALS" ]; then for img in ebusd-*.deb; do echo -n "upload \$img: "; curl -fs -u "\$UPLOAD_CREDENTIALS" -X POST --data-binary "@\$img" -H "Content-Type: application/octet-stream" "\$UPLOAD_URL/\$img?a=\$EBUSD_ARCH\&o=\$UPLOAD_OS\&v=\$EBUSD_VERSION" || echo "failed"; done; fi' - namesuffix='' -else - make='./make_debian.sh' - namesuffix='.release' -fi -for arch in $archs; do + namesuffix='.build' replaceTemplate -done - +fi