mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
In v12.32 "Build and push multi-arch image" took 27 of the docker job's 29 minutes. For each of seven platforms, six of them emulated, the Dockerfile installed a compiler toolchain, resolved and downloaded Node.js, reinstalled programs/server with npm, re-ran the prune, bump, trim and prune passes, and purged the toolchain again. That platform's .zip leg in release-all.yml had already done all of it, with the same scripts. Stage 1 (FROM --platform=$BUILDPLATFORM) now runs natively on the runner for each target. It downloads that target's .zip, checks it against the release's own .sha256sum, re-runs the telemetry check, reads bundle/node's ELF header to confirm the target CPU, and lays out /build and /usr/local/bin/node. The image's node is the .zip's own node: the file the leg resolved and verified, rather than a second download that had to match it. Stage 2 is the only part that runs as the target CPU. It adds the WeKan user, applies an OS update, installs file, libatomic1 and docker-cli, and copies stage 1's result. No npm and no compiler ever enter the image. The docker job read the base image from the first FROM; it now reads the last one, since the first is the build-machine stage. Stage 1 was run outside Docker against the real v12.32 s390x zip: the checksum, the telemetry check (47979 files) and the ELF check (machine 22) passed, and the layout was right. The ELF check rejects the same node when expected as ppc64le, and rejects a non-ELF file. No Docker build ran here. tests/dockerImageFromBundle.test.cjs pins the two stages, the verification, the per-architecture ELF numbers (shared with check-addon-arch.mjs), and that no reinstall, Node.js download or toolchain comes back. It fails on the previous Dockerfile. Nine tests pinned the old in-image steps; each now pins the new behaviour, with the reason recorded beside it. Thanks to xet7 !
40 lines
2.2 KiB
JavaScript
40 lines
2.2 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const { spawnSync } = require('node:child_process');
|
|
const read = file => fs.readFileSync(file, 'utf8');
|
|
|
|
test('runtime bundler rejects foreign architectures and preserves licensing', () => {
|
|
const result = spawnSync('python3', ['-B', 'tests/bundle-node-runtime.py'], { encoding: 'utf8' });
|
|
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
});
|
|
test('Docker keeps libatomic outside the removable build dependencies', () => {
|
|
const docker = read('Dockerfile');
|
|
assert.match(docker, /apt-get install[^\n]*file libatomic1/);
|
|
// There is no removable build-dependency list any more (nothing in the image
|
|
// is compiled); what must hold is that nothing purges it again.
|
|
assert.doesNotMatch(docker, /apt-get (?:remove|purge)[^\n]*libatomic1/);
|
|
assert.doesNotMatch((docker.match(/ENV BUILD_DEPS="[^"]*"/) || [''])[0], /libatomic1/);
|
|
});
|
|
test('native and emulated Linux bundles both package their own runtime', () => {
|
|
assert.match(read('releases/embed-verified-node.sh'), /python3 "\$here\/bundle-node-runtime.py" "\$dest" \|\| exit 1/);
|
|
const emulated = read('releases/install-node-for-arch.sh');
|
|
assert.match(emulated, /apt-install.sh[^\n]*libatomic1/);
|
|
assert.match(emulated, /bundle-node-runtime.py" \/bundle\/node/);
|
|
const launch = read('releases/ferretdb/start-wekan.sh');
|
|
assert.match(launch, /export LD_LIBRARY_PATH="\$DIR\/node-runtime\$\{LD_LIBRARY_PATH:\+:\$LD_LIBRARY_PATH\}"/);
|
|
});
|
|
test('AppImage and Flatpak require the bundled library and preserve the bundle', () => {
|
|
for (const name of ['AppImage', 'Flatpak']) {
|
|
const workflow = read(`.github/workflows/${name}.yml`);
|
|
assert.match(workflow, /for f in [^\n]*bundle\/node-runtime\/libatomic.so.1/);
|
|
assert.match(workflow, /cp -a bundle /);
|
|
}
|
|
});
|
|
test('Sandstorm includes and checks libatomic in its private library tree', () => {
|
|
const source = read('sandstorm-src/build-deps.sh');
|
|
assert.match(source, /libz.so.1 libatomic.so.1; do/);
|
|
assert.match(source, /\[ -f "\$DEPS\/lib\/x86_64-linux-gnu\/libatomic.so.1" \] \|\|/);
|
|
assert.match(source, /cp -L \/usr\/share\/doc\/libatomic1\/copyright/);
|
|
});
|