-
Notifications
You must be signed in to change notification settings - Fork 160
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
added support for private Docker registries #1666
Changes from all commits
7ff96c5
acde15d
0a78574
2a48b21
b173e8d
d55812d
73f49c6
a27816c
6bb8a46
3cf755e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,13 +207,14 @@ func (c dockerClient) StartBuildkitd(ctx context.Context, tag, name string, bc * | |
AutoRemove: true, | ||
} | ||
|
||
if bc.SetCA { | ||
if len(bc.RegistryName) > 0 { | ||
hostConfig.Mounts = append(hostConfig.Mounts, mount.Mount{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will removing this cause any side effect? |
||
Type: mount.TypeBind, | ||
Source: fileutil.DefaultConfigDir, | ||
Target: buildkitdCertPath, | ||
}) | ||
} | ||
|
||
cfg, err := bc.String() | ||
if err != nil { | ||
return "", errors.Wrap(err, "failed to generate buildkit config") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,21 +20,33 @@ import ( | |
) | ||
|
||
const buildkitConfigTemplate = ` | ||
[registry."{{ if .Registry }}{{ .Registry }}{{ else }}docker.io{{ end }}"]{{ if .Mirror }} | ||
mirrors = ["{{ .Mirror }}"]{{ end }} | ||
http = {{ .UseHTTP }} | ||
{{ if .SetCA}}ca=["/etc/registry/ca.pem"] | ||
[[registry."{{ if .Registry }}{{ .Registry }}{{ else }}docker.io{{ end }}".keypair]] | ||
key="/etc/registry/key.pem" | ||
cert="/etc/registry/cert.pem" | ||
{{ end }} | ||
[registry] | ||
{{- range $index, $value := .RegistryName }} | ||
[registry."{{ if $value }}{{ $value }}{{ else }}docker.io{{ end }}"] | ||
{{- if index $.UseHTTP $index }} | ||
http = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what if they want to specify different http/mirrors for different registries? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should make the mirror a string slice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kemingy advised me to leave the dockerhub-mirror command as is, since Docker mirrors are unrelated to private registries. I can change it, but then the command will be removed (the mirror config will be in the JSON file instead). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @kemingy WDYT |
||
{{- end }} | ||
{{- if $.Mirror }} | ||
mirrors = ["{{ $.Mirror }}"] | ||
{{- end }} | ||
{{- if index $.CaPath $index }} | ||
ca=["/etc/registry/{{ $value }}_ca.pem"] | ||
{{- end }} | ||
{{- if and (index $.CertPath $index) (index $.KeyPath $index) }} | ||
[[registry."{{ if $value }}{{ $value }}{{ else }}docker.io{{ end }}".keypair]] | ||
key="/etc/registry/{{ $value }}_key.pem" | ||
cert="/etc/registry/{{ $value }}_cert.pem" | ||
{{- end }} | ||
{{- end }} | ||
` | ||
|
||
type BuildkitConfig struct { | ||
Registry string | ||
Mirror string | ||
UseHTTP bool | ||
SetCA bool | ||
RegistryName []string | ||
CaPath []string | ||
CertPath []string | ||
KeyPath []string | ||
UseHTTP []bool | ||
Mirror string | ||
} | ||
|
||
func (c *BuildkitConfig) String() (string, error) { | ||
|
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.
If we're going to pass a JSON file, why not use the buildkit TOML file directly?
I think the main purpose of the CLI is to make it user-friendly. If the situation is complex, it's almost the same as setting up a buildkitd instance manually.
This decision will heavily affect the implementation. What do you think?
cc @gaocegege @RichhLi @ByronHsu
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.
How about providing the buildkit TOML directly to envd?
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.
Very good point. The problem with directly providing a TOML file is that the Docker mount won't be set up. I think this pr may not even be necessary because we might as well just set up buildkitd manually like you said. We will discuss this.
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.
@kemingy @gaocegege Would it be possible to keep the current envd implementation, and the only change we'll make is adding a command that accepts JSON input? And we'll add a check where users can only use one of the commands, not both at the same time. So it will be completely backward compatible.
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.
I'm okay with it.
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.
LGTM!
Will you implement it in this PR?
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.
Yes, or do you want it in different pr?
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.
No, I am just asking. Keeping in this PR LGTM.
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.
Hi @RichhLi Do you still need this PR?
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.
No, I merged this one: #1680