-
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
Add registry mirror support in Jib build plugins #3011
Merged
Merged
Conversation
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
Added tests and ready for review. But #3010 needs to go first. Will update CHANGELOG in the meantime. |
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java
Show resolved
Hide resolved
jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java
Show resolved
Hide resolved
jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStepTest.java
Show resolved
Hide resolved
loosebazooka
approved these changes
Jan 28, 2021
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java
Show resolved
Hide resolved
This was referenced Feb 10, 2021
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.
Towards #1396.
Supports only public mirrors such as
mirror.gcr.io
. (If a mirror requires credentials, it won't work.)I went with the simple approach to try the mirrors when pulling a base image manifest in
PullBaseImageStep
. The class sets up aRegistryClient
and returns it, so we just try pulling from mirrors and the actual registry until success. (So, this assumes that if a mirror returns a manifest with 200, all subsequent requests to pull blobs will succeed, which is not an unreasonable assumption.)Tested with the following config:
In my test, the first mirror
localhost:5000
always fails (connection error), but it doesn't fail the entire build. It triesmirror.gcr.io
next. Then, ifmirror.gcr.io
has cached the base image, Jib nevers contact Docker Hub. Ifmirror.gcr.io
returns 404, it correctly falls back to Docker Hub.