Repository navigation
build(docker): build JavaScript natively, only the runtime image per target - #212
Merged
Merged
Conversation
…target Cross-platform images were built entirely under QEMU emulation, so an arm64 image built on an x86 machine (or the reverse) ran every install and build emulated. Install and build stages now run on $BUILDPLATFORM: their output is JavaScript, identical for every target. Only the runtime stages, and the API's production install, run as the target platform. sharp is the one native module in Next's standalone output: the web build stage fetches its binaries for the target (bun install --os/--cpu/--libc, at the lockfile's version; musl because the runner is Alpine) and the runtime stage places them beside each traced copy of sharp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The install and build stages now run on
$BUILDPLATFORM(FROM --platform=$BUILDPLATFORM): the webbuilderand the APIpackagesstage. Before, the release workflow'slinux/amd64,linux/arm64build ran them under QEMU for the non-native platform. Their output is JavaScript, the same for every target. These still run as the target platform:bun install(msgpackr-extract, sharp)sharp is the one native module in the web app's standalone output. The build stage fetches its binaries for the target platform at the lockfile's version (
bun install --os=linux --libc=musl --cpu=<x64|arm64>). The runtime stage copies them beside each traced copy of sharp. musl is needed because the runner isnode:24-alpineand the builder is Debian: without--libc=musl, bun fetches only the glibc arm64 binary and sharp fails to load.Verification (local, x86_64 host,
--no-cache)nodeand renders a PNG.publish-docker-image.yamlneeds no change. buildx setsBUILDPLATFORM/TARGETARCH, and the build stages are shared by both platforms.Not verified: an actual push through the GitHub Actions workflow (no images were published), or booting the API against a database.