# debian:trixie (Debian 13), not ubuntu:26.04: Ubuntu publishes no linux/386 # image, which stopped the image from ever building for i386. Debian ships every # arch this image targets - amd64, arm64, 386, arm/v7, ppc64le, riscv64, s390x - # so ONE base covers them all, and it is the same base WeKan's per-arch .zip # bundles are already built in (releases/... build-extra-arches). # # The ONE it does not ship is arm/v6: debian:trixie's manifest list has arm/v5 # and arm/v7 and nothing between them. That matters because containerd treats a # LOWER ARM variant as compatible, so a linux/arm/v6 request does not fail - it # quietly resolves to the arm/v5 (armel, SOFT-float) image, whose loader and # glibc cannot run the hard-float node-armv6 in the armv6 bundle. The docker job # therefore asks this base what it publishes and drops a platform it lacks; see # docs/Platforms/FOSS/Container/Docker/CPU-platforms.md. # ── Stage 1: the release bundle, prepared ON THE BUILD MACHINE ─────────────── # # Everything a release bundle needs is already done when this runs: each # wekan--.zip was built by its own release-all.yml leg, with # programs/server installed, its native modules built for that CPU, the # security bumps applied, the tree trimmed and pruned, the telemetry check # passed, and the Node.js for that CPU embedded as bundle/node - resolved by # releases/resolve-node-source.sh and verified against the SHA256 its source # published (embed-verified-node.sh / install-node-for-arch.sh). # # This image used to do all of it AGAIN, inside the target platform: apt-get # a compiler toolchain, resolve and download Node.js, npm install, prune, bump, # trim, prune, and purge the toolchain - seven times, six of them under QEMU. # That was 27 of the docker job's 29 minutes in v12.32, for a result the .zip # already was. So this stage runs with --platform=$BUILDPLATFORM, natively on # the runner, for whichever TARGET it is building: it downloads that target's # .zip, checks it against the release's own .sha256sum, re-runs the telemetry # check, and checks that bundle/node really is a binary for the target CPU. # Nothing in it executes target code, so nothing is emulated. # # The image's node is the bundle's own node: the same file the .zip ships, # rather than a second download that had to agree with it. FROM --platform=$BUILDPLATFORM debian:trixie AS bundle ARG TARGETARCH ARG TARGETVARIANT ARG VERSION=13.20 ARG DEBIAN_FRONTEND=noninteractive COPY --chmod=755 releases/check-telemetry.py /tmp/check-telemetry.py COPY releases/risk-baseline.json /tmp/risk-baseline.json RUN < WeKan's own platform name, which is # the bundle .zip's name. amd64/arm64 have MongoDB Community; # ppc64le/s390x/riscv64 have no MongoDB server and ship FerretDB v1 instead (the # ferretdb binary is baked into their .zip and started by wekan-entrypoint.sh). # Debian's 32-bit ARM port is armhf (ARMv7, VFPv3-D16), which is what # linux/arm/v7 runs. ELF_MACHINE is the e_machine the bundle's node must carry. case "${TARGETARCH}" in "amd64") WEKAN_ARCH="amd64"; ELF_MACHINE=62 ;; "arm64") WEKAN_ARCH="arm64"; ELF_MACHINE=183 ;; "ppc64le") WEKAN_ARCH="ppc64le"; ELF_MACHINE=21 ;; "s390x") WEKAN_ARCH="s390x"; ELF_MACHINE=22 ;; "riscv64") WEKAN_ARCH="riscv64"; ELF_MACHINE=243 ;; "386") WEKAN_ARCH="i386"; ELF_MACHINE=3 ;; # BOTH linux/arm/v6 and linux/arm/v7 arrive here as TARGETARCH=arm - the CPU # generation is in TARGETVARIANT, not in TARGETARCH - so this branch MUST read # the variant. Mapping "arm" straight to armhf, as it did, would hand an ARMv6 # board (Raspberry Pi 1, Zero) the armhf bundle, which is built to Debian's # ARMv7-A baseline and whose instructions that board cannot execute. "arm") ELF_MACHINE=40 case "${TARGETVARIANT}" in "v6") WEKAN_ARCH="armv6" ;; # v7, and an unset variant, are Debian's armhf port: ARMv7-A, # VFPv3-D16 hard-float. That is what linux/arm/v7 runs. "v7"|"") WEKAN_ARCH="armhf" ;; # v5 is armel: FerretDB and the MongoDB tools publish it (they are Go), # but Node.js does not exist for ARMv5 at all, so there is no bundle to # put in an image and refusing is the only honest answer. *) echo "Unsupported 32-bit ARM variant: ${TARGETVARIANT} (only v6 and v7 have a WeKan bundle)"; exit 1 ;; esac ;; *) echo "Unsupported architecture: ${TARGETARCH}${TARGETVARIANT:+/${TARGETVARIANT}}"; exit 1 ;; esac mkdir -p /work cd /work # Retry the release-asset download: even though the CI `docker` job needs the # `release` job (so the asset is already uploaded), GitHub's # releases/download// URL can briefly return 404 right after upload # (CDN/propagation lag). A plain wget treats 404 as fatal, which failed the # build; retry on transient HTTP errors so propagation lag no longer breaks it. WEKAN_ZIP="wekan-${VERSION}-${WEKAN_ARCH}.zip" WEKAN_ZIP_URL="https://github.com/wekan/wekan/releases/download/v${VERSION}/${WEKAN_ZIP}" wget --tries=20 --waitretry=20 --retry-on-http-error=404,403,500,502,503 "${WEKAN_ZIP_URL}" \ || { echo "Failed to download ${WEKAN_ZIP_URL} after retries"; exit 8; } wget --tries=20 --waitretry=20 --retry-on-http-error=404,403,500,502,503 "${WEKAN_ZIP_URL}.sha256sum" \ || { echo "Failed to download ${WEKAN_ZIP_URL}.sha256sum after retries"; exit 8; } # The file the image is built from is the file the release published. sha256sum -c "${WEKAN_ZIP}.sha256sum" unzip -q "${WEKAN_ZIP}" rm "${WEKAN_ZIP}" "${WEKAN_ZIP}.sha256sum" python3 /tmp/check-telemetry.py --bundle ./bundle # The bundle's own node is the image's node, so it must be FOR the target CPU: # a .zip of the wrong architecture would otherwise become an image whose node # cannot start, and nothing here runs it to find out. test -s bundle/node || { echo "${WEKAN_ZIP} has no bundle/node"; exit 1; } python3 - "${ELF_MACHINE}" bundle/node <<'EOP' import struct, sys want, path = int(sys.argv[1]), sys.argv[2] head = open(path, 'rb').read(20) if head[:4] != b'\x7fELF': sys.exit(f'{path} is not an ELF binary') got = struct.unpack('>H' if head[5] == 2 else '