switch to using docker buildx with multi-arch

This commit is contained in:
John
2021-11-10 20:16:26 +01:00
parent c09ba1e686
commit 6faa52bdd4
14 changed files with 139 additions and 453 deletions
+19 -9
View File
@@ -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 \ RUN apt-get update && apt-get install -y \
libmosquitto-dev libstdc++6 libc6 libgcc1 \ libmosquitto-dev libstdc++6 libc6 libgcc1 \
@@ -9,16 +10,20 @@ RUN apt-get update && apt-get install -y \
WORKDIR /build WORKDIR /build
ENV EBUSD_ARCH amd64 ARG TARGETARCH
ENV EBUSD_VERSION 21.3 ARG TARGETVARIANT
ARG EBUSD_VERSION
RUN git clone https://github.com/john30/ebusd.git /build \ ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT
&& ./make_debian.sh 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 \ RUN apt-get update && apt-get install -y \
libmosquitto1 libstdc++6 libc6 libgcc1 \ libmosquitto1 libstdc++6 libc6 libgcc1 \
@@ -26,8 +31,13 @@ RUN apt-get update && apt-get install -y \
LABEL maintainer "ebusd@ebusd.eu" LABEL maintainer "ebusd@ebusd.eu"
ENV EBUSD_VERSION 21.3 ARG TARGETARCH
ENV EBUSD_ARCH amd64 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" LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}-devel"
@@ -39,6 +49,6 @@ RUN dpkg -i ebusd.deb \
EXPOSE 8888 EXPOSE 8888
COPY docker-entrypoint.sh / COPY --from=build /build/contrib/docker/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-f", "--scanconfig"] CMD ["-f", "--scanconfig"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
+20 -10
View File
@@ -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 \ RUN apt-get update && apt-get install -y \
libmosquitto-dev libstdc++6 libc6 libgcc1 \ libmosquitto-dev libstdc++6 libc6 libgcc1 \
@@ -9,16 +10,20 @@ RUN apt-get update && apt-get install -y \
WORKDIR /build WORKDIR /build
ENV EBUSD_ARCH amd64 ARG TARGETARCH
ENV EBUSD_VERSION 21.3 ARG TARGETVARIANT
ARG EBUSD_VERSION
RUN git clone https://github.com/john30/ebusd.git /build \ ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT
&& ./make_debian.sh 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 \ RUN apt-get update && apt-get install -y \
libmosquitto1 libstdc++6 libc6 libgcc1 \ libmosquitto1 libstdc++6 libc6 libgcc1 \
@@ -26,12 +31,17 @@ RUN apt-get update && apt-get install -y \
LABEL maintainer "ebusd@ebusd.eu" LABEL maintainer "ebusd@ebusd.eu"
ENV EBUSD_VERSION 21.3 ARG TARGETARCH
ENV EBUSD_ARCH amd64 ARG TARGETVARIANT
ARG EBUSD_VERSION
ARG EBUSD_IMAGE
ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT
ENV EBUSD_VERSION $EBUSD_VERSION
LABEL version "${EBUSD_VERSION}-${EBUSD_ARCH}" 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 \ RUN dpkg -i ebusd.deb \
&& ebusd -V \ && ebusd -V \
@@ -39,6 +49,6 @@ RUN dpkg -i ebusd.deb \
EXPOSE 8888 EXPOSE 8888
COPY docker-entrypoint.sh / COPY contrib/docker/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-f", "--scanconfig"] CMD ["-f", "--scanconfig"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
-44
View File
@@ -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"]
+24 -14
View File
@@ -1,6 +1,7 @@
%QEMU_FROM_LINE% ARG BASE_IMAGE
FROM %BASE_IMAGE% as build
%QEMU_FROM_COPY% FROM $BASE_IMAGE as build
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libmosquitto-dev libstdc++6 libc6 libgcc1 \ libmosquitto-dev libstdc++6 libc6 libgcc1 \
curl \ curl \
@@ -9,36 +10,45 @@ RUN apt-get update && apt-get install -y \
WORKDIR /build WORKDIR /build
ENV EBUSD_ARCH %EBUSD_ARCH% ARG TARGETARCH
ENV EBUSD_VERSION %EBUSD_VERSION% ARG TARGETVARIANT
ARG EBUSD_VERSION
RUN git clone https://github.com/john30/ebusd.git /build \ ENV EBUSD_ARCH $TARGETARCH$TARGETVARIANT
&& %EBUSD_MAKE% ENV EBUSD_VERSION $EBUSD_VERSION
ADD . /build
RUN %EBUSD_MAKE%
%EBUSD_UPLOAD_LINES% %EBUSD_UPLOAD_LINES%
FROM %BASE_IMAGE%-slim FROM $BASE_IMAGE-slim as image
%QEMU_FROM_COPY%
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libmosquitto1 libstdc++6 libc6 libgcc1 \ libmosquitto1 libstdc++6 libc6 libgcc1 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
LABEL maintainer "ebusd@ebusd.eu" LABEL maintainer "ebusd@ebusd.eu"
ENV EBUSD_VERSION %EBUSD_VERSION% ARG TARGETARCH
ENV EBUSD_ARCH %EBUSD_ARCH% 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%" 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 \ RUN dpkg -i ebusd.deb \
&& ebusd -V \ && ebusd -V \
&& rm -f ebusd.deb%EXTRA_RM% && rm -f ebusd.deb
EXPOSE 8888 EXPOSE 8888
COPY docker-entrypoint.sh / %EBUSD_COPYENTRY%
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-f", "--scanconfig"] CMD ["-f", "--scanconfig"]
+4 -5
View File
@@ -2,8 +2,8 @@ ebusd Docker image
================== ==================
An [ebusd](https://github.com/john30/ebusd/) Docker image is available on the 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 [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/). [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. 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 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: The image is able to run on any of the following architectures and the right image will be picked automatically:
* amd64 * amd64
* i386 * i386
* arm32v5
* arm32v7 * arm32v7
* arm64v8 * arm64v8
In addition to the default "latest" tag, a development set of images is available with "devel" tag. This is built Due to changes of docker hub policies, the development set of images with "devel" tag are currently not automatically
automatically with every commit to the git repository. Run the following command to use it: built with every commit to the git repository. Run the following command to use it:
> docker pull john30/ebusd:devel > docker pull john30/ebusd:devel
+52 -17
View File
@@ -1,20 +1,55 @@
#!/bin/bash #!/bin/bash
archs='amd64 i386 arm32v5 arm32v7 arm64v8' if [[ -z "$1" ]]; then
images='stretch buster bullseye' echo "usage: $0 [release|UPLOADHOST]"
UPLOAD_URL='http://'`hostname`'/ebusdreleaseupload.php' echo " without arguments: build and push devel docker images"
UPLOAD_CREDENTIALS='anonymous:build' echo " release: build and push release docker images from latest release binaries"
for image in $images; do echo " UPLOADHOST: build Debian release packages (with and without MQTT) and upload them to UPLOADHOST"
dir=$image exit 1
mkdir -p $dir
BASE_IMAGE=debian:$image ./update.sh $dir/
for arch in $archs; do
if [ "$arch" != "amd64" ]; then
suffix=".$arch"
else
suffix=''
fi 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 . archs=linux/amd64,linux/386,linux/arm/v7,linux/arm64
done if [[ -z "$1" ]] || [[ "x$1" == "xrelease" ]]; then
rm -rf $dir UPLOAD_URL=
done else
UPLOAD_URL="http://$1/ebusdreleaseupload.php"
fi
UPLOAD_CREDENTIALS='anonymous:build'
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
+16 -42
View File
@@ -1,63 +1,37 @@
#!/bin/bash #!/bin/bash
DEFAULT_IMAGE=debian:bullseye
EBUSD_VERSION=`cat ../../VERSION`
archs='amd64 i386 arm32v5:arm arm32v7:arm arm64v8:aarch64'
function replaceTemplate () { function replaceTemplate () {
prefix= file="Dockerfile${namesuffix}"
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}"
sed \ 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_MAKE%#${make}#g" \
-e "s#%EBUSD_VERSION%#${EBUSD_VERSION}#g" \
-e "s#%EBUSD_VERSION_VARIANT%#${version_variant}#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_UPLOAD_LINES%#${upload_lines}#g" \
-e "s#%EBUSD_COPYDEB%#${copydeb}#g" \
-e "s#%EBUSD_COPYENTRY%#${copyentry}#g" \
Dockerfile.template > "$file" Dockerfile.template > "$file"
echo "updated $file" echo "updated $file"
} }
if [[ -z "$1" ]]; then # devel update
# devel updates
version_variant='-devel' version_variant='-devel'
make='./make_debian.sh' make='./make_debian.sh'
dir='' upload_lines=''
upload_line='' copydeb='COPY --from=build /build/ebusd-*_mqtt1.deb ebusd.deb'
copyentry='COPY --from=build /build/contrib/docker/docker-entrypoint.sh /'
namesuffix='' namesuffix=''
for arch in $archs; do
replaceTemplate replaceTemplate
done
fi
# release updates # release update
version_variant='' 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 if [[ -n "$1" ]]; then
# build releases update
make='./make_all.sh' 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' 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='' namesuffix='.build'
else
make='./make_debian.sh'
namesuffix='.release'
fi
for arch in $archs; do
replaceTemplate replaceTemplate
done fi