Skip to content

Order the image build around the Wine prefix - #16

Merged
BenA-SA merged 1 commit into
masterfrom
perf/build-layer-ordering
Sep 20, 2026
Merged

BenA-SA merged 1 commit into
masterfrom
perf/build-layer-ordering

Conversation

@BenA-SA

@BenA-SA BenA-SA commented Sep 20, 2026

Copy link
Copy Markdown
Owner

The most expensive layer in Containerfile.full is RUN /opt/scripts/build-prefix.sh — wineboot, DXVK, VKD3D, then downloading the proprietary TPV installer and driving Inno Setup under Xvfb with a 900 s timeout.

Two things sat above it and invalidated it:

Step Before After
COPY --from=qzbuild (QZ binary) 12 18
COPY scripts/ 14 19
RUN build-prefix.sh 18 15

So editing any script, or bumping QZ_COMMIT, re-ran the whole Wine prefix build. Measured on a one-line edit to scripts/entrypoint.sh, the log shows it really happening:

==> wineboot (initialising /opt/tpv/wine-template)
==> DXVK
==> TPV launcher (Inno Setup; /VERYSILENT ...)
==> TPV launcher installed into the image: TPVirtual-Launcher.exe

Now only build-prefix.sh and xvfb-lib.sh are copied before it; the QZ binary and the rest of scripts/ follow it. The image is unchanged — only the layer order moves.

Measured

Before After
Image size 6.69 GB 6.63 GB −60 MB
Full build 438 s 385 s −12%
Rebuild after a script edit 67 s 3 s −95%
Prefix layer on that rebuild re-ran Using cache

Both full builds ran with only 3 and 5 cached layers, so that comparison isn't a warm-cache artefact.

Packages

Removed, after checking every script for the binaries it invokes: gnupg (7.1 MB, 26 packages — trixie's apt verifies the signed-by WineHQ key through Sequoia; confirmed apt-get update resolves winehq-stable with neither gnupg nor gpgv installed), vulkan-tools and cabextract (referenced nowhere), tar (already Essential, installed nothing).

Kept deliberately: curl, because entrypoint.sh re-downloads the installer at runtime when the launcher is missing; zstd for the VKD3D tarball; procps on suspicion rather than evidence.

Also collapsed the three apt-get update runs into one.

Not in this PR

The two larger size levers need a real ride to validate, so they stay separable: dropping i386 multiarch (77 MB of downloads — it is enabled for the PE32 installer, a build-time need, but if any 32-bit code runs at runtime the ride breaks) and debian:trixie-slim (43 MB).

Reasoning in full: docs/adr/0008-order-the-image-build-around-the-wine-prefix.md.

The most expensive layer is build-prefix.sh: wineboot, DXVK, VKD3D, then
downloading the proprietary TPV installer and driving Inno Setup under
Xvfb with a 900 s timeout. The QZ binary and the whole scripts/ directory
were copied in above it, so editing any script -- or bumping QZ_COMMIT --
re-ran all of that.

Copy only the two scripts the prefix build needs before it, and move the
QZ binary and the rest of scripts/ after it. The image is unchanged; only
the layer order moves. A one-line edit to entrypoint.sh now rebuilds in
3 s instead of 67 s, with the prefix layer reading 'Using cache' rather
than reinstalling TPV.

Also drop packages nothing uses: gnupg (26 packages; trixie's apt
verifies the signed-by WineHQ key through Sequoia, confirmed with
neither gnupg nor gpgv installed), vulkan-tools and cabextract (both
referenced nowhere), and tar (already Essential). curl stays -- the
entrypoint re-downloads the installer at runtime -- and so do zstd, for
the VKD3D tarball, and procps.

Collapse the three apt-get update runs into one by adding the WineHQ and
Mesa repositories before it.

Full build 438 s to 385 s, image 6.69 GB to 6.63 GB. See docs/adr/0008.
@BenA-SA
BenA-SA merged commit 88de852 into master Sep 20, 2026
4 checks passed
@BenA-SA
BenA-SA deleted the perf/build-layer-ordering branch September 20, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant