ENT-13786: Reproducible container builds#2249
Open
larsewi wants to merge 4 commits into
Open
Conversation
Pin embedded build timestamps in the container build entrypoint so two builds of the same source produce identical binaries. Honored by OpenSSL, Apache httpd, PHP, OpenLDAP, dpkg-buildpackage, and rpmbuild. Derived from core's HEAD commit time, honoring a caller-provided value if already set. Ticket: ENT-13786 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Composer's default falls back to cloning vendored packages, leaving .git directories in the vendor tree with non-deterministic pack files and reflog timestamps. --prefer-dist downloads zipballs instead, so no .git directory is created. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
PHP's phar embeds time(NULL) into every manifest entry, making phar.phar non-reproducible. Patch ext/phar to honor SOURCE_DATE_EPOCH when set, falling back to time(NULL) otherwise. Wire the patch into both the rpm spec and debian rules. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Composer falls back to git clone when GitHub's anonymous zipball API rate limit is hit, so --prefer-dist alone is not enough to guarantee a .git-free vendor tree. Strip any .git directories that end up under vendor/ after the composer installs. Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
craigcomstock
approved these changes
May 12, 2026
Contributor
craigcomstock
left a comment
There was a problem hiding this comment.
Is it the case that we could run the build-in-container-inner.sh script by itself on a host and build? We are putting a lot of important logic in there and I wonder if we shouldn't refactor things to make it more obvious that we could run this script "anywhere" so to speak?
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.
Make the container build path produce bit-identical packages across two cache-cleared runs.
Four commits:
SOURCE_DATE_EPOCHat the top ofbuild-in-container-inner.sh. Honored by OpenSSL, Apache httpd, PHP, OpenLDAP,dpkg-buildpackage, andrpmbuild. Pins embedded build timestamps.composer install --prefer-distto avoid leaving.git/directories in the vendor tree. Hint, not enforced — see commit 4.ext/pharhonorsSOURCE_DATE_EPOCH. Upstream PHP's phar packer unconditionally embedstime(NULL)into manifest entries. Patches four call sites inext/phar/{phar,util,tar,zip}.c. Worth submitting upstream to php-src separately so we don't carry it indefinitely..git/after install.--prefer-distfalls back to source when GitHub's anonymous zipball API rate-limits (60 req/hour; mission-portal has dozens of packages). Matches what CI does accidentally via--exclude=".git"inbuild-scripts/transfer-to-buildmachine.