add binfmt switch

This commit is contained in:
Albie 2021-08-10 16:43:28 +01:00
parent 52b4cc2805
commit 9ba08fde5b
3 changed files with 20 additions and 0 deletions

View File

@ -99,6 +99,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
Destination: &settings.Daemon.BuildkitConfig,
},
&cli.BoolFlag{
Name: "daemon.install-binfmt",
Usage: "run bimfmt binaries installer",
EnvVars: []string{"PLUGIN_INSTALL_BINFMT"},
Destination: &settings.Daemon.InstallBinfmt,
},
&cli.StringFlag{
Name: "dockerfile",
Usage: "build dockerfile",

View File

@ -52,6 +52,14 @@ func commandInfo() *exec.Cmd {
return exec.Command(dockerExe, "info")
}
func commandInstallBinfmt() *exec.Cmd {
return exec.Command(
dockerExe, "run",
"--privileged", "--rm",
"tonistiigi/binfmt", "--install all"
)
}
func commandBuilder(daemon Daemon) *exec.Cmd {
args := []string{
"buildx",

View File

@ -27,6 +27,7 @@ type Daemon struct {
IPv6 bool // Docker daemon IPv6 networking
Experimental bool // Docker daemon enable experimental mode
BuildkitConfig string // Docker buildkit config
InstallBinfmt bool // Install binfmt binaries for better emulation support
}
// Login defines Docker login parameters.
@ -160,6 +161,11 @@ func (p *Plugin) Execute() error {
p.settings.Build.Squash = false
}
// run the binfmt docker image if requested
if p.settings.Daemon.InstallBinfmt {
commandInstallBinfmt()
}
// add proxy build args
addProxyBuildArgs(&p.settings.Build)