From 6d33558acdb86815078ef1eae9fc59eddcd615e6 Mon Sep 17 00:00:00 2001 From: woodpecker-bot Date: Fri, 9 Feb 2024 00:10:35 +0000 Subject: [PATCH 1/7] chore(deps): update woodpeckerci/plugin-docker-buildx docker tag to v3.1.0 --- .woodpecker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index ee4b55f..aff2648 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,7 +7,7 @@ when: variables: - &golang "golang:1.22" - - &build_plugin "woodpeckerci/plugin-docker-buildx:3.0.1" + - &build_plugin "woodpeckerci/plugin-docker-buildx:3.1.0" - base_settings: &base_buildx_settings platforms: "linux/amd64,linux/arm64" dockerfile: Dockerfile.multiarch From 1c8d8b1c7a2bb823ec63957c231cab15a18a9a9e Mon Sep 17 00:00:00 2001 From: woodpecker-bot Date: Sat, 10 Feb 2024 00:09:25 +0000 Subject: [PATCH 2/7] fix(deps): update module github.com/aws/aws-sdk-go to v1.50.15 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c53b166..e5eb4ef 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( codeberg.org/6543/go-yaml2json v1.0.0 github.com/6543/go-version v1.3.1 - github.com/aws/aws-sdk-go v1.50.13 + github.com/aws/aws-sdk-go v1.50.15 github.com/drone-plugins/drone-plugin-lib v0.4.2 github.com/joho/godotenv v1.5.1 github.com/pelletier/go-toml/v2 v2.1.1 diff --git a/go.sum b/go.sum index 4c12125..92baf35 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,8 @@ github.com/aws/aws-sdk-go v1.50.5 h1:H2Aadcgwr7a2aqS6ZwcE+l1mA6ZrTseYCvjw2QLmxIA github.com/aws/aws-sdk-go v1.50.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.50.13 h1:yeXram2g7q8uKkQkAEeZyk9FmPzxI4UpGwAZGZtEGmM= github.com/aws/aws-sdk-go v1.50.13/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.50.15 h1:wEMnPfEQQFaoIJwuO18zq/vtG4Ft7NxQ3r9xlEi/8zg= +github.com/aws/aws-sdk-go v1.50.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From e92ff9072c3c475e673fa0540ad2fa21c7847776 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 15 Feb 2024 19:15:57 +0000 Subject: [PATCH 3/7] Add secret option (#135) close #134 ref: https://docs.docker.com/build/building/secrets Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/woodpecker-plugins/docker-buildx/pulls/135 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Simon Vieille Co-committed-by: Simon Vieille --- cmd/docker-buildx/config.go | 6 ++++++ docs.md | 8 ++++---- plugin/docker.go | 3 +++ plugin/impl.go | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/docker-buildx/config.go b/cmd/docker-buildx/config.go index 05705f3..9e56a4e 100644 --- a/cmd/docker-buildx/config.go +++ b/cmd/docker-buildx/config.go @@ -183,6 +183,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { Usage: "forwards environment variables as custom arguments to the build", Destination: &settings.Build.ArgsEnv, }, + &cli.StringSliceFlag{ + Name: "secrets", + EnvVars: []string{"PLUGIN_SECRETS"}, + Usage: "sets custom secret arguments for the build", + Destination: &settings.Build.Secrets, + }, &cli.BoolFlag{ Name: "quiet", EnvVars: []string{"PLUGIN_QUIET"}, diff --git a/docs.md b/docs.md index 3f8ce32..b7e2e0d 100644 --- a/docs.md +++ b/docs.md @@ -8,6 +8,7 @@ containerImage: woodpeckerci/plugin-docker-buildx containerImageUrl: https://hub.docker.com/r/woodpeckerci/plugin-docker-buildx url: https://codeberg.org/woodpecker-plugins/docker-buildx --- + Woodpecker CI plugin to build multiarch Docker images with buildx. This plugin is a fork of [thegeeklab/drone-docker-buildx](https://github.com/thegeeklab/drone-docker-buildx/) which itself is a fork of [drone-plugins/drone-docker](https://github.com/drone-plugins/drone-docker). ## Features @@ -27,9 +28,8 @@ It will automatically generate buildkit configuration to use custom CA certifica ## Settings - | Settings Name | Default | Description | -| ------------------------- | ------------------------------- | ---------------------------------------------------- | +| ----------------------- | ----------------------------- | -------------------------------------------------- | | `dry-run` | `false` | disables docker push | | `repo` | _none_ | sets repository name for the image (can be a list) | | `username` | _none_ | sets username to authenticates with | @@ -91,9 +91,8 @@ docker-build: ## Advanced Settings - | Settings Name | Default | Description | -| ------------------------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| ----------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | `mirror` | _none_ | sets a registry mirror to pull images | | `storage_driver` | _none_ | sets the docker daemon storage driver | | `storage_path` | `/var/lib/docker` | sets the docker daemon storage path | @@ -118,6 +117,7 @@ docker-build: | `default_labels`/`auto_labels` | `true` | sets docker image labels based on git information | | `build_args` | _none_ | sets custom build arguments for the build | | `build_args_from_env` | _none_ | forwards environment variables as custom arguments to the build | +| `secrets` | _none_ | Sets the build secrets for the build | | `quiet` | `false` | enables suppression of the build output | | `target` | _none_ | sets the build target to use | | `cache_from` | _none_ | sets configuration for cache source | diff --git a/plugin/docker.go b/plugin/docker.go index e966b37..4b82743 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -94,6 +94,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { for _, arg := range append(defaultBuildArgs, build.Args.Value()...) { args = append(args, "--build-arg", arg) } + for _, secret := range build.Secrets.Value() { + args = append(args, "--secret", secret) + } for _, host := range build.AddHost.Value() { args = append(args, "--add-host", host) } diff --git a/plugin/impl.go b/plugin/impl.go index 563d03d..55708bf 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -69,6 +69,7 @@ type Build struct { Platforms cli.StringSlice // Docker build target platforms Args cli.StringSlice // Docker build args ArgsEnv cli.StringSlice // Docker build args from env + Secrets cli.StringSlice // Docker build secret Target string // Docker build target Output string // Docker build output Pull bool // Docker build pull From 1b406fbab4ad89c52cb5898d8b2e4b60ba7b10e4 Mon Sep 17 00:00:00 2001 From: woodpecker-bot Date: Sat, 17 Feb 2024 00:06:14 +0000 Subject: [PATCH 4/7] fix(deps): update module github.com/aws/aws-sdk-go to v1.50.20 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e5eb4ef..4ead723 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( codeberg.org/6543/go-yaml2json v1.0.0 github.com/6543/go-version v1.3.1 - github.com/aws/aws-sdk-go v1.50.15 + github.com/aws/aws-sdk-go v1.50.20 github.com/drone-plugins/drone-plugin-lib v0.4.2 github.com/joho/godotenv v1.5.1 github.com/pelletier/go-toml/v2 v2.1.1 diff --git a/go.sum b/go.sum index 92baf35..a94ab28 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ github.com/aws/aws-sdk-go v1.50.13 h1:yeXram2g7q8uKkQkAEeZyk9FmPzxI4UpGwAZGZtEGm github.com/aws/aws-sdk-go v1.50.13/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.50.15 h1:wEMnPfEQQFaoIJwuO18zq/vtG4Ft7NxQ3r9xlEi/8zg= github.com/aws/aws-sdk-go v1.50.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.50.20 h1:xfAnSDVf/azIWTVQXQODp89bubvCS85r70O3nuQ4dnE= +github.com/aws/aws-sdk-go v1.50.20/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From c3960e7057b08b2b5e0e969b2ffb8b385c1534bb Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 23 Feb 2024 15:31:52 +0100 Subject: [PATCH 5/7] add extra_build_params setting --- cmd/docker-buildx/config.go | 6 ++++ plugin/docker.go | 3 ++ plugin/impl.go | 55 +++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/cmd/docker-buildx/config.go b/cmd/docker-buildx/config.go index 9e56a4e..718816a 100644 --- a/cmd/docker-buildx/config.go +++ b/cmd/docker-buildx/config.go @@ -189,6 +189,12 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag { Usage: "sets custom secret arguments for the build", Destination: &settings.Build.Secrets, }, + &cli.StringFlag{ + Name: "extra-args", + EnvVars: []string{"PLUGIN_EXTRA_BUILD_PARAMS"}, + Usage: "sets the extra build params", + Destination: &settings.Build.ExtraBuildParams, + }, &cli.BoolFlag{ Name: "quiet", EnvVars: []string{"PLUGIN_QUIET"}, diff --git a/plugin/docker.go b/plugin/docker.go index 4b82743..d8e44b4 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -106,6 +106,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { if build.Output != "" { args = append(args, "--output", build.Output) } + if build.ExtraBuildParams != "" { + args = append(args, build.ExtraBuildParams) + } if build.Quiet { args = append(args, "--quiet") } diff --git a/plugin/impl.go b/plugin/impl.go index 55708bf..118be71 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -54,33 +54,34 @@ type Login struct { // Build defines Docker build parameters. type Build struct { - Remote string // Git remote URL - Ref string // Git commit ref - Branch string // Git repository branch - Dockerfile string // Docker build Dockerfile - Context string // Docker build context - TagsAuto bool // Docker build auto tag - TagsDefaultName string // Docker build auto tag name override - TagsSuffix string // Docker build tags with suffix - Tags cli.StringSlice // Docker build tags - TagsFile string // Docker build tags read from an file - LabelsAuto bool // Docker build auto labels - Labels cli.StringSlice // Docker build labels - Platforms cli.StringSlice // Docker build target platforms - Args cli.StringSlice // Docker build args - ArgsEnv cli.StringSlice // Docker build args from env - Secrets cli.StringSlice // Docker build secret - Target string // Docker build target - Output string // Docker build output - Pull bool // Docker build pull - CacheFrom string // Docker build cache-from - CacheTo string // Docker build cache-to - CacheImages cli.StringSlice // Docker build cache images - Compress bool // Docker build compress - Repo cli.StringSlice // Docker build repository - NoCache bool // Docker build no-cache - AddHost cli.StringSlice // Docker build add-host - Quiet bool // Docker build quiet + Remote string // Git remote URL + Ref string // Git commit ref + Branch string // Git repository branch + Dockerfile string // Docker build Dockerfile + Context string // Docker build context + TagsAuto bool // Docker build auto tag + TagsDefaultName string // Docker build auto tag name override + TagsSuffix string // Docker build tags with suffix + Tags cli.StringSlice // Docker build tags + TagsFile string // Docker build tags read from an file + LabelsAuto bool // Docker build auto labels + Labels cli.StringSlice // Docker build labels + Platforms cli.StringSlice // Docker build target platforms + Args cli.StringSlice // Docker build args + ArgsEnv cli.StringSlice // Docker build args from env + Secrets cli.StringSlice // Docker build secret + ExtraBuildParams string // Docker build extra build args + Target string // Docker build target + Output string // Docker build output + Pull bool // Docker build pull + CacheFrom string // Docker build cache-from + CacheTo string // Docker build cache-to + CacheImages cli.StringSlice // Docker build cache images + Compress bool // Docker build compress + Repo cli.StringSlice // Docker build repository + NoCache bool // Docker build no-cache + AddHost cli.StringSlice // Docker build add-host + Quiet bool // Docker build quiet } // Settings for the Plugin. From d1fa5d614d2e8a69ec114ba781b0d5768eddc763 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 23 Feb 2024 15:32:08 +0100 Subject: [PATCH 6/7] add extra_build_params documentation and example --- docs.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs.md b/docs.md index b7e2e0d..270811b 100644 --- a/docs.md +++ b/docs.md @@ -118,6 +118,7 @@ docker-build: | `build_args` | _none_ | sets custom build arguments for the build | | `build_args_from_env` | _none_ | forwards environment variables as custom arguments to the build | | `secrets` | _none_ | Sets the build secrets for the build | +| `extra_build_params` | _none_ | Sets the extra build params | | `quiet` | `false` | enables suppression of the build output | | `target` | _none_ | sets the build target to use | | `cache_from` | _none_ | sets configuration for cache source | @@ -164,6 +165,15 @@ settings: from_secret: aws_secret_access_key ``` +## Add extra build params + +```yaml +settings: + repo: a6543/tmp,codeberg.org/6543/tmp + tag: demo + extra_build_params: "--secret id=secret_key,src=secret_key --build-arg no_proxy=.prod.mydomain.com,.next.mydomain.com" +``` + ## Using `plugin-docker-buildx` behind a proxy When performing a docker build behind a corporate proxy one needs to pass through the proxy settings to the plugin. From 04f640ba692072ae3c713f31b4816ba600443144 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 26 Feb 2024 09:27:03 +0100 Subject: [PATCH 7/7] split extra build params --- plugin/docker.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/docker.go b/plugin/docker.go index d8e44b4..9a88af5 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -107,7 +107,9 @@ func commandBuild(build Build, dryrun bool) *exec.Cmd { args = append(args, "--output", build.Output) } if build.ExtraBuildParams != "" { - args = append(args, build.ExtraBuildParams) + for _, param := range strings.Split(build.ExtraBuildParams, " ") { + args = append(args, param) + } } if build.Quiet { args = append(args, "--quiet")