Uh oh!
There was an error while loading. Please reload this page.
bake: git auth support for remote definitions - #2363
Conversation
b04c3f0 to
35bbed2Compare23b8fd2 to
d7a8f4dCompare@tonistiigi While adding tests I discovered a strange behavior with git source in BuildKit when authenticated. It seems most of the requests send the authorization header but not the one when checking the default branch in https://github.com/moby/buildkit/blob/ad5a64c68f20435c52a51db73ef9246d6a3feba6/source/git/source.go#L732 even if header is set in See https://github.com/docker/buildx/actions/runs/8465151975/job/23191259148#step:7:635 So for now in this test I just check the very first request is authenticated but I think we need a fix on BuildKit side. Works fine though when testing directly: Editseems to be a limitation with Edit2after testing with: It seems we could use Test on gitlab: Works with basic auth as well. Also we should make sure this is a server supporting Git's smart service by checking |
d7a8f4d to
1009504CompareUh oh!
There was an error while loading. Please reload this page.
thaJeztah
commented
Mar 28, 2024
Will these always be for bake only, or could these be for "build" as well? (curious if the |
Only bake, this is used to build remote bake definitions. For build we already use secrets to build from a remote Git context. |
thaJeztah
commented
Mar 28, 2024
Ah! So.. naive question; if that doesn't require special env-vars; why does bake need them? |
1009504 to
a686f8dComparethaJeztah
commented
Mar 28, 2024
Re-reading; you mention remote definitions (so equivalent to "remote dockerfile"); I know |
crazy-max
commented
Mar 28, 2024
Because a remote definition is not a build context per-say. We can't set secrets directly as this will be used also in the underlying builds from the definition. What @tonistiigi suggested in #2360 (comment) with a builtin target name could work but UX wise this is not great. |
a686f8d to
c7e9dabCompare
Yes indeed I don't think we have that for the Dockerfile atm. For bake we have "builtin" ways to use either a local or remote context, as well as merging local and remote definitions: https://docs.docker.com/build/bake/remote-definition/ @dvdksn Talking about merging local and remote bake definitions, I don't think we have this documented atm #1838 Edit: nevermind https://docs.docker.com/build/bake/remote-definition/#remote-definition-with-the---file-flag |
c7e9dab to
0da453dCompare| } | ||
| var gitAuthSecrets []*controllerapi.Secret | ||
| if _, ok := os.LookupEnv("BUILDX_BAKE_GIT_AUTH_TOKEN"); ok { |
There was a problem hiding this comment.
Probably out of scope, but unclear to me how the controller takes Env keys as input. Doesn't the controller have its own env if it is running in another process?
There was a problem hiding this comment.
Hum good point, it seems to work when connecting to local controller. I don't think there is another process except when using --invoke and setting envs through invoke config:
buildx/controller/pb/controller.proto
Line 199 in a7d59ae
| if err == nil { | ||
| session = append(session, ssh) | ||
| var sshSpecs []*controllerapi.SSH | ||
| if v := os.Getenv("BUILDX_BAKE_GIT_SSH"); v != "" { |
There was a problem hiding this comment.
ID of this needs to be set with MountSSHSock() if not default. Setting it to other ID would not work otherwise. So probably it should just be the path.
020ac59 to
8cb85e5CompareSigned-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
8cb85e5 to
4d39259Compare
fixes#2360
Adds support for Git auth when using remote bake definitions through
BUILDX_BAKE_GIT_AUTH_TOKENandBUILDX_BAKE_GIT_AUTH_HEADERenvs var that will setGIT_AUTH_TOKENandGIT_AUTH_HEADERsecrets respectively, matching https://github.com/moby/buildkit/blob/ad5a64c68f20435c52a51db73ef9246d6a3feba6/client/llb/source.go#L270-L271Also adds
BUILDX_BAKE_GIT_SSHto be consistent so user can provide SSH sock paths.