Skip to content
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 44 commits into from
Jan 28, 2021
Merged

Conversation

chanseokoh
Copy link
Member

@chanseokoh chanseokoh commented Jan 21, 2021

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 a RegistryClient 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:

{
  "disableUpdateCheck":false,
  "registryMirrors": [
    {
      "registry": "registry-1.docker.io",
      "mirrors": ["localhost:5000", "mirror.gcr.io"]
    }
  ]
}

In my test, the first mirror localhost:5000 always fails (connection error), but it doesn't fail the entire build. It tries mirror.gcr.io next. Then, if mirror.gcr.io has cached the base image, Jib nevers contact Docker Hub. If mirror.gcr.io returns 404, it correctly falls back to Docker Hub.

@google-cla google-cla bot added the cla: yes label Jan 21, 2021
@chanseokoh chanseokoh marked this pull request as ready for review January 22, 2021 21:49
@chanseokoh
Copy link
Member Author

Added tests and ready for review. But #3010 needs to go first.

Will update CHANGELOG in the meantime.

@chanseokoh chanseokoh merged commit 0f80a14 into master Jan 28, 2021
@chanseokoh chanseokoh deleted the docker-mirror-final branch January 28, 2021 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants