Skip to content

Commit cd11b0a

Browse files
committed
Support reproducible builds (except packages)
See docker-library/official-images issue 16044 - For Debian, `/var/log/*` is removed as they contain timestamps - For Debian, `/var/cache/ldconfig/aux-cache` is 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/world` and `/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 or later. > > - To reproduce the base image by the hash, reproducers may: > - modify the `FROM` instruction in Dockerfile manually > - or, use the `CONVERT` action of source policies to replace the base image. > <https://github.com/moby/buildkit/blob/v0.13.2/docs/build-repro.md> > > - To reproduce packages, see the `RUN` instruction hook proposed in > moby/buildkit#4576 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent cc3386b commit cd11b0a

File tree

9 files changed

+20
-10
lines changed

9 files changed

+20
-10
lines changed

1.22/alpine3.19/Dockerfile

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.22/alpine3.20/Dockerfile

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.22/bookworm/Dockerfile

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.22/bullseye/Dockerfile

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.23/alpine3.19/Dockerfile

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.23/alpine3.20/Dockerfile

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.23/bookworm/Dockerfile

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.23/bullseye/Dockerfile

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile-linux.template

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ENV GOLANG_VERSION {{ .version }}
5353
RUN set -eux; \
5454
now="$(date '+%s')"; \
5555
{{ if is_alpine then ( -}}
56-
apk add --no-cache --virtual .fetch-deps \
56+
apk add --no-cache --virtual .fetch-deps=0 \
5757
ca-certificates \
5858
gnupg \
5959
# busybox's "tar" doesn't handle directory mtime correctly, so our SOURCE_DATE_EPOCH lookup doesn't work (the mtime of "/usr/local/go" always ends up being the extraction timestamp)
@@ -163,7 +163,9 @@ RUN set -eux; \
163163
make \
164164
pkg-config \
165165
; \
166-
rm -rf /var/lib/apt/lists/*
166+
rm -rf /var/lib/apt/lists/* ; \
167+
# clean up for reproducibility
168+
rm -rf /var/log/* /var/cache/ldconfig/aux-cache
167169
{{ ) end -}}
168170

169171
ENV GOLANG_VERSION {{ .version }}

0 commit comments

Comments
 (0)