-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Address Base Image Reproducibility #224
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
77cac45
Adds directory for proposals.
coollog 277beee
Fixes link.
coollog fc5bca7
Fixes link.
coollog ac29a3f
Fixes link.
coollog 0c1c4a0
Fixes link.
coollog 5e0b943
Adds clause about approval.
coollog 7e6f2b2
Adds proposal for addressing base image reproducibility.
coollog 2030171
Merge branch 'master' into proposal-reproducibility
coollog 8a4f985
Merge branch 'master' into proposal-reproducibility
coollog c3cb0d0
Merge branch 'master' into proposal-reproducibility
coollog a953ad8
Merge branch 'master' into proposal-reproducibility
coollog ed5a306
Removes status.
coollog f0b1dc9
Merge branch 'proposal-reproducibility' of github.com:google/jib into…
coollog 30436cc
Merge branch 'master' into proposal-reproducibility
coollog b701554
Merge branch 'master' into proposal-reproducibility
coollog adb267e
Merge branch 'master' into proposal-reproducibility
coollog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Proposal: Address Base Image Reproducibility | ||
|
||
## Motivation | ||
|
||
One of the main goals of Jib is to be able to build images reproducibly, such that the same contents always creates the same images. It does this by wiping the timestamps and user information from the files in the Java application layers (dependencies, resources, classes). However, it does not do the same for the base image layers, which, by default, are from the latest [`gcr.io/distroless/java`](gcr.io/distroless/java) image. This may be unexpected behaviors since by default, reproducibility is on (the user may switch it off using the `enableReproducibleBuilds` parameter for Maven or the `reproducible` parameter for Gradle). | ||
|
||
### Terminology | ||
|
||
Image **reference** refers to the full reference for an image. This can be as short as `busybox` (which refers to the `library/busybox` **repository** on the Docker Hub **registry**), or as long as `gcr.io/distroless/java@sha256:0135c8b1adb3ed906f521973f825cea3fcdcb9b0db2f4012cc05480bf4d53fd6` (which refers to the image with **digest** `sha256:0135c8b1adb3...` in the `distroless/java` repository on the `gcr.io` registry). An image reference without a specific digest or tag, like `gcr.io/distroless/java`, defaults to the `latest` **tag**, which always refers to the newest digest in that repository. | ||
|
||
## Problem | ||
|
||
The main problem is that the reproducibility feature of Jib does not actually guaranteed *for the image*, but rather only guarantees reproducibility *for the application layers*. This is a bug. | ||
|
||
The problem arises in a common workflow where the developer expects reproducibility: | ||
|
||
1. The developer commits a change as version 123. | ||
1. The developer builds the image for that commit - results in image A. | ||
1. On another machine (possibly in prod), that developer checks out version 123 and builds the image - this should have resulted in image A again. | ||
|
||
However, since Jib uses the latest version of the [gcr.io/distroless/java](gcr.io/distroless/java) image (which is updated rather frequently - about every 2 weeks) as the base image to build the application layers on top of, if a newer [gcr.io/distroless/java](gcr.io/distroless/java) is latest, the rebuild would result in a different image than expected. | ||
|
||
## Goals | ||
|
||
- Maintain ease-of-use (no unnecessary extra configuration, at least for the default case) | ||
- Preferable: Keep reproducibility on by default | ||
|
||
## Solution | ||
|
||
Jib will still use `gcr.io/distroless/java` by default, since in development, users may wish to keep at the latest base image. An alternative would be to use a specific digest of `gcr.io/distroless/java` but that would involve tying a version of Jib to a version of distroless. | ||
|
||
The `reproducible`/`enableReproducibleBuilds` configuration will be removed. Application layers (dependencies, resources, classes) will always be reproducible. | ||
|
||
Reproducibility will be guaranteed if the user specifies a specific digest to use for a base image. This can be specified as a fully-qualified custom base image, or as a `tag` configuration (Maven). | ||
|
||
The user will be warned if the base image used is tagged with `latest` such that reproducibility is not guaranteed. Note that this warning is given by default. | ||
|
||
So, the logic flow would be: | ||
|
||
1. Jib uses `gcr.io/distroless/java` as the base image. | ||
1. If the user specifies a different image to use as the base image, use that. | ||
1. The user can configure a specific digest to use - `tag` for Maven, and `from.image` for Gradle. | ||
1. If the final tag/digest is still `latest`, warn the user that reproducibility is not guaranteed due a changeable base image, and suggest the user to specify a specific digest. | ||
|
||
## Implementation | ||
|
||
- Remove the `reproducible`/`enableReproducibleBuilds` configuration and always build application layers reproducibly. | ||
- When validating the `jib-maven-plugin`/`jib-gradle-plugin` configuration, warn the user if the base image uses a `latest` tag. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍