Skip to content

Support reproducible builds (except packages)#38

Closed
AkihiroSuda wants to merge 1 commit into
tianon:masterfrom
AkihiroSuda:repro
Closed

Support reproducible builds (except packages)#38
AkihiroSuda wants to merge 1 commit into
tianon:masterfrom
AkihiroSuda:repro

Conversation

@AkihiroSuda
Copy link
Copy Markdown

@AkihiroSuda AkihiroSuda commented May 1, 2024

See:

  • Reproducible builds docker-library/official-images#16044

  • SOURCE_DATE_EPOCH is added. The value is consumed by the build scripts to make the binary reproducible.

  • 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:

Comment thread Dockerfile.template Outdated
Comment on lines +22 to +25
# SOURCE_DATE_EPOCH is consumed by build scripts
ARG SOURCE_DATE_EPOCH

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this is unobjectionable, but I'm not in favor of ARG.

Suggested change
# SOURCE_DATE_EPOCH is consumed by build scripts
ARG SOURCE_DATE_EPOCH

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could you explain the problem?
Isn't it quite common to specify the epoch for repro builds?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SOURCE_DATE_EPOCH has been already used in the meta scripts, no?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tianon Please let me know how I can make progress on this PR (and other PRs tracked in docker-library/official-images#16044) 🙏

Do you prefer the SOURCE_DATE_EPOCH to be set to the timestamp of bash.tar.gz? ( As in golang)

I can update this PR like that if you like, but I think having the "global" ARG SOURCE_DATE_EPOCH here still makes sense, as SOURCE_DATE_EPOCH also applies to apk commands, etc.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tianon @tonistiigi

Updated the PR to take SOURCE_DATE_EPOCH from the source material (as in golang):

SOURCE_DATE_EPOCH="$(find /usr/src/bash -type f -exec stat -c '%Y' {} + | sort -nr | head -n1)"

Let me know if this solves your concern.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely removed ARG SOURCE_DATE_EPOCH

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this (and other PRs in docker-library/official-images#16044) mergeable? 🙏 @tianon @tonistiigi

@AkihiroSuda
Copy link
Copy Markdown
Author

ping 🙇‍♂️ @tianon

See docker-library/official-images issue 16044

- `SOURCE_DATE_EPOCH` is added.
  The value is consumed by the build scripts to make the binary reproducible.

- 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 issue 4576
>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
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.

2 participants