Compare commits
No commits in common. "8d04efc34abece8afda1daf275deeac869735a86" and "38b9f475bbb7c341bec260fcd37ae830504b3e31" have entirely different histories.
8d04efc34a
...
38b9f475bb
@ -1,13 +1,9 @@
|
||||
variables:
|
||||
- &golang 'golang:1.20'
|
||||
- &platforms 'linux/amd64,linux/arm64'
|
||||
- &golang 'golang:1.18'
|
||||
- &build_plugin 'woodpeckerci/plugin-docker-buildx:2'
|
||||
- base_settings: &base_buildx_settings
|
||||
platforms: 'linux/amd64,linux/arm64'
|
||||
dockerfile: Dockerfile.multiarch
|
||||
auto_tag: true
|
||||
repo: git.polynom.me/papatutuwawa/docker-buildx
|
||||
|
||||
steps:
|
||||
pipeline:
|
||||
vendor:
|
||||
image: *golang
|
||||
commands: go mod vendor
|
||||
@ -20,8 +16,9 @@ steps:
|
||||
image: *build_plugin
|
||||
pull: true
|
||||
settings:
|
||||
<<: *base_buildx_settings
|
||||
repo: test
|
||||
platforms: *platforms
|
||||
repo: woodpeckerci/plugin-docker-buildx
|
||||
dockerfile: Dockerfile.multiarch
|
||||
dry_run: true
|
||||
when:
|
||||
event: pull_request
|
||||
@ -30,10 +27,19 @@ steps:
|
||||
publish:
|
||||
image: *build_plugin
|
||||
settings:
|
||||
<<: *base_buildx_settings
|
||||
platforms: *platforms
|
||||
repo: woodpeckerci/plugin-docker-buildx,codeberg.org/woodpecker-plugins/docker-buildx
|
||||
auto_tag: true
|
||||
dockerfile: Dockerfile.multiarch
|
||||
logins:
|
||||
# Default DockerHub login
|
||||
- registry: https://index.docker.io/v1/
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
# Additional Codeberg login
|
||||
- registry: https://git.polynom.me
|
||||
- registry: https://codeberg.org
|
||||
username:
|
||||
from_secret: cb_username
|
||||
password:
|
||||
|
@ -1,6 +1,6 @@
|
||||
ARG BUILDX_VERSION=0.11.0
|
||||
ARG BUILDX_VERSION=0.9.1
|
||||
ARG DOCKER_VERSION=20.10-dind
|
||||
ARG GOLANG_VERSION=1.20
|
||||
ARG GOLANG_VERSION=1.18
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:${GOLANG_VERSION} as build
|
||||
|
||||
|
@ -4,7 +4,9 @@
|
||||
<img alt="Get it on Codeberg" src="https://codeberg.org/Codeberg/GetItOnCodeberg/media/branch/main/get-it-on-neon-blue.png" height="60">
|
||||
</a>
|
||||
|
||||
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). You can find the full documentation at [woodpecker-ci.org](https://woodpecker-ci.org/plugins/Docker%20Buildx) ([docs.md](./docs.md)).
|
||||
Woodpecker CI plugin to build multiarch Docker images with 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). You can find the full documentation at You can find the full documentation at [woodpecker-ci.org](https://woodpecker-ci.org/plugins/Docker%20Buildx).
|
||||
|
||||
## Contributors
|
||||
|
||||
|
@ -121,12 +121,6 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
||||
FilePath: ".tags",
|
||||
Destination: &settings.Build.Tags,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "tags.file",
|
||||
EnvVars: []string{"PLUGIN_TAGS_FILE", "PLUGIN_TAG_FILE"},
|
||||
Usage: "overwrites tags flag with values find in set file",
|
||||
Destination: &settings.Build.TagsFile,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "tags.auto",
|
||||
EnvVars: []string{"PLUGIN_AUTO_TAG"},
|
||||
@ -159,11 +153,11 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
|
||||
Value: true,
|
||||
Destination: &settings.Build.LabelsAuto,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
&cli.StringSliceFlag{
|
||||
Name: "args",
|
||||
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
|
||||
Usage: "sets custom build arguments for the build. Must be a JSON string",
|
||||
Destination: &settings.Build.ArgsRaw,
|
||||
Usage: "sets custom build arguments for the build",
|
||||
Destination: &settings.Build.Args,
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "args-from-env",
|
||||
|
@ -20,10 +20,6 @@ func main() {
|
||||
godotenv.Overload("/run/drone/env")
|
||||
}
|
||||
|
||||
if envFile, set := os.LookupEnv("PLUGIN_ENV_FILE"); set {
|
||||
godotenv.Overload(envFile)
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
Name: "docker-buildx",
|
||||
Usage: "build docker container with DinD and buildx",
|
||||
|
14
docs.md
14
docs.md
@ -9,7 +9,7 @@ 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).
|
||||
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). You can find the full documentation at You can find the full documentation at [woodpecker-plugins.codeberg.page](https://woodpecker-plugins.codeberg.page/plugins/drone-docker-buildx).
|
||||
|
||||
## Features
|
||||
|
||||
@ -37,7 +37,7 @@ It will automatically generate buildkit configuration to use custom CA certifica
|
||||
| `email` | *none* | sets email address to authenticates with
|
||||
| `registry` | `https://index.docker.io/v1/` | sets docker registry to authenticate with
|
||||
| `dockerfile` | `Dockerfile` | sets dockerfile to use for the image build
|
||||
| `tag`/`tags` | *none* | sets repository tags to use for the image
|
||||
| `tag`/`tags` | @".tags" | sets repository tags to use for the image
|
||||
| `platforms` | *none* | sets target platform for build
|
||||
|
||||
## auto_tag
|
||||
@ -48,7 +48,7 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
```yml
|
||||
publish-next-agent:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
secrets: [docker_username, docker_password]
|
||||
@ -62,7 +62,7 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
||||
event: push
|
||||
```
|
||||
|
||||
```yaml
|
||||
```yml
|
||||
publish:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
@ -75,7 +75,7 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
||||
from_secret: cb_token
|
||||
```
|
||||
|
||||
```yaml
|
||||
```yml
|
||||
docker-build:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
@ -102,7 +102,6 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
||||
| `debug` | `false` | enables verbose debug mode for the docker daemon
|
||||
| `daemon_off` | `false` | disables the startup of the docker daemon
|
||||
| `buildkit_config` | *none* | sets content of the docker [buildkit TOML config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md)
|
||||
| `tags_file` | *none* | overwrites `tags` option with values find in specified file
|
||||
| `context` | `.` | sets the path of the build context to use
|
||||
| `auto_tag` | `false` | generates tag names automatically based on git branch and git tag, tags supplied via `tags` are additionally added to the auto_tags without suffix
|
||||
| `default_suffix"`/`auto_tag_suffix`| *none* | generates tag names with the given suffix
|
||||
@ -122,13 +121,12 @@ If it's not a tag event, and no default branch, automated tags are skipped.
|
||||
| `add_host` | *none* | sets additional host:ip mapping
|
||||
| `output` | *none* | sets build output in format `type=<type>[,<key>=<value>]`
|
||||
| `logins` | *none* | option to log into multiple registries
|
||||
| `env_file` | *none* | load env vars from specified file
|
||||
|
||||
## Multi registry push example
|
||||
|
||||
Only supported with `woodpecker >= 1.0.0` (next-da997fa3).
|
||||
|
||||
```yaml
|
||||
```yml
|
||||
settings:
|
||||
repo: a6543/tmp,codeberg.org/6543/tmp
|
||||
tag: demo
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module codeberg.org/woodpecker-plugins/plugin-docker-buildx
|
||||
|
||||
go 1.20
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
codeberg.org/6543/go-yaml2json v0.3.0
|
||||
|
@ -12,8 +12,6 @@ import (
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"codeberg.org/woodpecker-plugins/plugin-docker-buildx/utils"
|
||||
)
|
||||
|
||||
// Daemon defines Docker daemon parameters.
|
||||
@ -54,11 +52,9 @@ type Build struct {
|
||||
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
|
||||
ArgsRaw string // Docker build args (as JSON)
|
||||
Args cli.StringSlice // Docker build args
|
||||
ArgsEnv cli.StringSlice // Docker build args from env
|
||||
Target string // Docker build target
|
||||
@ -88,26 +84,6 @@ func (l Login) anonymous() bool {
|
||||
return l.Username == "" || l.Password == ""
|
||||
}
|
||||
|
||||
// Parse the provided build args into b.Args
|
||||
func (b Build) BuildArgs() {
|
||||
if len(b.ArgsRaw) > 0 {
|
||||
buildArgsRaw := map[string]string{}
|
||||
err := json.Unmarshal([]byte(b.ArgsRaw), &buildArgsRaw)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to parse build args: %s", err)
|
||||
}
|
||||
|
||||
for key, value := range buildArgsRaw {
|
||||
b.Args = *cli.NewStringSlice(
|
||||
append(
|
||||
b.Args.Value(),
|
||||
fmt.Sprintf("%s=%s", key, value),
|
||||
)...,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init initialise plugin settings
|
||||
func (p *Plugin) InitSettings() error {
|
||||
if p.settings.LoginsRaw != "" {
|
||||
@ -147,22 +123,6 @@ func (p *Plugin) Validate() error {
|
||||
}
|
||||
}
|
||||
|
||||
// overload tags flag with tags.file if set
|
||||
if p.settings.Build.TagsFile != "" {
|
||||
tagsFile, err := os.ReadFile(p.settings.Build.TagsFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read tags file: %w", err)
|
||||
}
|
||||
|
||||
// split file content into slice of tags
|
||||
tagsFileList := strings.Split(strings.TrimSpace(string(tagsFile)), "\n")
|
||||
// trim space of each tag
|
||||
tagsFileList = utils.Map(tagsFileList, func(s string) string { return strings.TrimSpace(s) })
|
||||
|
||||
// finally overwrite
|
||||
p.settings.Build.Tags = *cli.NewStringSlice(tagsFileList...)
|
||||
}
|
||||
|
||||
if p.settings.Build.TagsAuto {
|
||||
// we only generate tags on default branch or an tag event
|
||||
if UseDefaultTag(
|
||||
@ -248,8 +208,6 @@ func (p *Plugin) writeBuildkitConfig() error {
|
||||
|
||||
// Execute provides the implementation of the plugin.
|
||||
func (p *Plugin) Execute() error {
|
||||
p.settings.Build.BuildArgs()
|
||||
|
||||
// start the Docker daemon server
|
||||
if !p.settings.Daemon.Disabled {
|
||||
// If no custom DNS value set start internal DNS server
|
||||
|
@ -1,9 +0,0 @@
|
||||
package utils
|
||||
|
||||
func Map[T any](in []T, fn func(T) T) []T {
|
||||
out := in
|
||||
for i := range in {
|
||||
out[i] = fn(out[i])
|
||||
}
|
||||
return out
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMap(t *testing.T) {
|
||||
ints := []int{1, 2, 3, 4}
|
||||
ints = Map(ints, func(i int) int { return i * 10 })
|
||||
assert.EqualValues(t, []int{10, 20, 30, 40}, ints)
|
||||
|
||||
sl := []string{"a ", "b", " c"}
|
||||
sl = Map(sl, func(s string) string { return "#" + strings.TrimSpace(s) })
|
||||
assert.EqualValues(t, []string{"#a", "#b", "#c"}, sl)
|
||||
}
|
Loading…
Reference in New Issue
Block a user