Add internal DNS server if no custom DNS is set (#45)

Fixes #44

Co-authored-by: Lauris BH <lauris@nix.lv>
Reviewed-on: https://codeberg.org/woodpecker-plugins/plugin-docker-buildx/pulls/45
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lafriks@noreply.codeberg.org>
Co-committed-by: Lauris BH <lafriks@noreply.codeberg.org>
This commit is contained in:
Lauris BH
2022-11-23 14:01:45 +00:00
committed by 6543
parent 8a70e48182
commit a2d26878e7
4 changed files with 65 additions and 0 deletions

View File

@@ -209,6 +209,17 @@ func (p *Plugin) writeBuildkitConfig() error {
func (p *Plugin) Execute() error {
// start the Docker daemon server
if !p.settings.Daemon.Disabled {
// If no custom DNS value set start internal DNS server
if len(p.settings.Daemon.DNS.Value()) == 0 {
ip, err := getContainerIP()
if err != nil {
logrus.Warnf("error detecting IP address: %v", err)
} else if ip != "" {
p.startCoredns()
p.settings.Daemon.DNS.Set(ip)
}
}
p.startDaemon()
}