Support reproducible builds (except packages)
Background:
- docker-library/official-images#16044
Alternative to:
- #248
-
SOURCE_DATE_EPOCHis added. The value is consumed by the build scripts to make thehttpdbinary reproducible. -
GNU implementation of
wgetis executed with--no-hststo disable creating/root/.wget-hsts -
For Debian,
/var/log/*is removed as they contain timestamps -
For Debian,
/var/cache/ldconfig/aux-cacheis removed as they contain inode numbers, etc. -
For Alpine, virtual package versions are pinned to "0" to eliminate the timestamp-based version numbers that appear in
/etc/apk/worldand/lib/apk/db/installed
[!NOTE] The following topics are NOT covered by this commit:
To reproduce file timestamps in layers, BuildKit has to be executed with
--output type=<TYPE>,rewrite-timestamp=true. Needs BuildKit v0.13.0-beta1 or later.To reproduce the base image by the hash, reproducers may:
- modify the
FROMinstruction in Dockerfile manually- or, use the
CONVERTaction of source policies to replace the base image. https://github.com/moby/buildkit/blob/v0.13.0-beta1/docs/build-repro.mdTo reproduce Debian packages, reproducers may:
- modify the
RUNinstructions in the Dockerfile to rewrite/etc/apt/sources.listto use http://snapshot.debian.org, and restore/etc/apt/sources.listat the end of the instruction (See the rejected PR #248)- or, use "instruction hook" https://github.com/moby/buildkit/issues/4576
@tianon @yosifkit PTAL 🙏
@tianon @yosifkit
I think this is good to merge. Unlike https://github.com/docker-library/httpd/pull/248 , this does not suffer from the slow apt-get.