mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-09 17:20:39 +00:00
feat: add option to specify buildkit config file path (#32)
This commit is contained in:
parent
380e304e7a
commit
904641bf10
@ -93,6 +93,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
||||
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
|
||||
Destination: &settings.Daemon.Disabled,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "daemon.buildkit-config",
|
||||
Usage: "location of buildkit config file",
|
||||
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
|
||||
Destination: &settings.Daemon.BuildkitConfig,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "dockerfile",
|
||||
Usage: "build dockerfile",
|
||||
|
@ -52,8 +52,18 @@ func commandInfo() *exec.Cmd {
|
||||
return exec.Command(dockerExe, "info")
|
||||
}
|
||||
|
||||
func commandBuilder() *exec.Cmd {
|
||||
return exec.Command(dockerExe, "buildx", "create", "--use")
|
||||
func commandBuilder(daemon Daemon) *exec.Cmd {
|
||||
args := []string{
|
||||
"buildx",
|
||||
"create",
|
||||
"--use",
|
||||
}
|
||||
|
||||
if daemon.BuildkitConfig != "" {
|
||||
args = append(args, "--config", daemon.BuildkitConfig)
|
||||
}
|
||||
|
||||
return exec.Command(dockerExe, args...)
|
||||
}
|
||||
|
||||
func commandBuildx() *exec.Cmd {
|
||||
|
@ -14,19 +14,20 @@ import (
|
||||
|
||||
// Daemon defines Docker daemon parameters.
|
||||
type Daemon struct {
|
||||
Registry string // Docker registry
|
||||
Mirror string // Docker registry mirror
|
||||
Insecure bool // Docker daemon enable insecure registries
|
||||
StorageDriver string // Docker daemon storage driver
|
||||
StoragePath string // Docker daemon storage path
|
||||
Disabled bool // DOcker daemon is disabled (already running)
|
||||
Debug bool // Docker daemon started in debug mode
|
||||
Bip string // Docker daemon network bridge IP address
|
||||
DNS cli.StringSlice // Docker daemon dns server
|
||||
DNSSearch cli.StringSlice // Docker daemon dns search domain
|
||||
MTU string // Docker daemon mtu setting
|
||||
IPv6 bool // Docker daemon IPv6 networking
|
||||
Experimental bool // Docker daemon enable experimental mode
|
||||
Registry string // Docker registry
|
||||
Mirror string // Docker registry mirror
|
||||
Insecure bool // Docker daemon enable insecure registries
|
||||
StorageDriver string // Docker daemon storage driver
|
||||
StoragePath string // Docker daemon storage path
|
||||
Disabled bool // DOcker daemon is disabled (already running)
|
||||
Debug bool // Docker daemon started in debug mode
|
||||
Bip string // Docker daemon network bridge IP address
|
||||
DNS cli.StringSlice // Docker daemon dns server
|
||||
DNSSearch cli.StringSlice // Docker daemon dns search domain
|
||||
MTU string // Docker daemon mtu setting
|
||||
IPv6 bool // Docker daemon IPv6 networking
|
||||
Experimental bool // Docker daemon enable experimental mode
|
||||
BuildkitConfig string // Docker buildkit config file
|
||||
}
|
||||
|
||||
// Login defines Docker login parameters.
|
||||
@ -77,6 +78,12 @@ func (p *Plugin) Validate() error {
|
||||
p.settings.Build.Ref = p.pipeline.Commit.Ref
|
||||
p.settings.Daemon.Registry = p.settings.Login.Registry
|
||||
|
||||
if p.settings.Daemon.BuildkitConfig != "" {
|
||||
if _, err := os.Stat(p.settings.Daemon.BuildkitConfig); err != nil && os.IsNotExist(err) {
|
||||
return fmt.Errorf("given buildkit config file not found")
|
||||
}
|
||||
}
|
||||
|
||||
if p.settings.Build.TagsAuto {
|
||||
// return true if tag event or default branch
|
||||
if UseDefaultTag(
|
||||
@ -159,7 +166,7 @@ func (p *Plugin) Execute() error {
|
||||
var cmds []*exec.Cmd
|
||||
cmds = append(cmds, commandVersion()) // docker version
|
||||
cmds = append(cmds, commandInfo()) // docker info
|
||||
cmds = append(cmds, commandBuilder())
|
||||
cmds = append(cmds, commandBuilder(p.settings.Daemon))
|
||||
cmds = append(cmds, commandBuildx())
|
||||
|
||||
// pre-pull cache images
|
||||
|
Loading…
Reference in New Issue
Block a user