diff --git a/cmd/drone-docker-buildx/config.go b/cmd/drone-docker-buildx/config.go index 581962b..d028b34 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/drone-docker-buildx/config.go @@ -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", diff --git a/plugin/docker.go b/plugin/docker.go index 903c6cc..e61401e 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -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", diff --git a/plugin/impl.go b/plugin/impl.go index bfdadd7..524d187 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -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)