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

all bake targets should share the same AuthProvider #2116

Closed
nicks opened this issue Nov 14, 2023 · 3 comments · Fixed by #2147
Closed

all bake targets should share the same AuthProvider #2116

nicks opened this issue Nov 14, 2023 · 3 comments · Fixed by #2147
Assignees
Labels
kind/enhancement New feature or request

Comments

@nicks
Copy link
Contributor

nicks commented Nov 14, 2023

Description

Currently, when you build N targets, each target creates its own AuthProvider. So if each target needs to pull from index.docker.io, they need to make N round trips to the credential helper.

bo.Session = append(bo.Session, authprovider.NewDockerAuthProvider(dockerConfig, nil))

It would be better if all N targets used the same AuthProvider, so they only need to fetch credentials once.

@crazy-max
Copy link
Member

crazy-max commented Nov 20, 2023

It seems slightly related to moby/buildkit#1432 where we would need a shared session with auth attachable for invoked targets. Found @tonistiigi had an implementation for bake: tonistiigi/buildx@bake...bake-shared-session. Would need some cleanup and also handle named contexts.

@tonistiigi
Copy link
Member

@crazy-max We can't just put all bake targets behind same session as only some configurations are safe. Eg. targets may use different contexts/secrets that need to be kept separate and can't overwrite each other.

The interesting aspect about this specific case is why should it matter that all authproviders are different. The pull is still synchronized between all targets and happens only once and only one pull means only one authentication as well. This can also not be used for combining multiple pulls of different images under same credentials as all tokens are scoped by a specific repository and action.

@nicks
Copy link
Contributor Author

nicks commented Nov 23, 2023

Ah, there are two tokens at play.

You're right that the auth.docker.io tokens are scoped per registry.

I'm talking about the docker-credential-helper tokens, which are scoped by host. They're cached here : https://github.com/moby/buildkit/blob/5997099827e676c4b6ce5774c98ade2483e0afe7/session/auth/authprovider/authprovider.go#L247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants