Dockerfile: install build dependencies correctly and support source builds - #2214
Open
axl89 wants to merge 1 commit into
Open
Dockerfile: install build dependencies correctly and support source builds#2214axl89 wants to merge 1 commit into
axl89 wants to merge 1 commit into
Conversation
…uilds
The builder stage passes `gcc` as the argument to `--virtual`, which names
the virtual package rather than adding it to the install list. apk therefore
creates a meta-package called "gcc" containing only libffi-dev and musl-dev,
and the C compiler is never installed:
(5/5) Installing gcc (20260826.214227)
This stays invisible on linux/amd64 and linux/arm64 -- the only platforms
built in docker-publish.yml -- because every dependency resolves to a
prebuilt musllinux wheel and nothing is ever compiled.
On platforms without wheels the stage fails. bcrypt, which is the default
value of DEPENDENCIES, ships musllinux wheels for x86_64 and aarch64 only,
so on linux/arm/v7 pip builds it from source and the build aborts with:
error: can't find Rust compiler
This package requires Rust >=1.64.0.
Rename the virtual package to .build-deps so gcc is actually installed, and
add rust and cargo so the Rust-based extensions can be compiled where no
wheel is published.
Only the builder stage is affected; it is discarded after the venv is copied,
so the published image is unchanged in size. Verified linux/amd64 still
builds and linux/arm/v7 now builds and serves requests.
Collaborator
|
@kalsi-avneet - please review |
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.
Problem
The builder stage passes
gccas the argument to--virtual, which names the virtual package rather than adding it to the install list:RUN apk add --no-cache --virtual gcc libffi-dev musl-dev \apk creates a meta-package called
gcccontaining onlylibffi-devandmusl-dev, and the C compiler is never installed. It is visible in the build output:That is the placeholder, not the compiler.
This stays invisible on
linux/amd64andlinux/arm64— the only platforms built indocker-publish.yml— because every dependency resolves to a prebuilt musllinux wheel and nothing is ever compiled. CI is green and the published images are fine.On platforms without wheels the stage fails.
bcryptis the default value ofDEPENDENCIESand ships musllinux wheels forx86_64andaarch64only, so onlinux/arm/v7pip builds it from source:Reproduce with:
Fix
Rename the virtual package to
.build-depssogccis actually installed, and addrustandcargoso Rust-based extensions can be compiled where no wheel is published.Only the builder stage is touched. It is discarded once
/app/venvis copied, so the published image is unchanged in size — the cost is a few seconds ofapk addat build time on platforms that do not need it.Verification
linux/amd64— builds, no regression,radicale --versionOK.linux/arm/v7— builds (previously failed), container starts and serves requests:Runtime check inside the armv7 image:
Notes
The first half of this (the
--virtualmisuse) is a bug regardless of architecture — any source build needing a C compiler currently fails silently.The second half (
rust cargo) is what makes armv7 viable. If you would rather not pay theapk addcost on the platforms you publish, it can be made conditional instead:Happy to switch to that, or to drop the
rust/cargopart entirely and keep only the--virtualfix, whichever you prefer. Also happy to addlinux/arm/v7to theplatformslist indocker-publish.ymlin a follow-up if that is of interest.