0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-06-02 18:29:42 +02:00

Compare commits

...

112 Commits
v2.0.0 ... main

Author SHA1 Message Date
renovate[bot]
7bf14e3635 chore(docker): update docker:26.1-dind docker digest to 76ba10a 2024-05-31 03:17:59 +00:00
renovate[bot]
02bf2bc68d chore(deps): update dependency golangci/golangci-lint to v1.59.0 2024-05-27 03:09:30 +00:00
renovate[bot]
36018940e1
chore(deps): update dependency docker/buildx to v0.14.1 (#185)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-24 09:41:45 +02:00
renovate[bot]
258dbbe73f
fix(deps): update module github.com/rs/zerolog to v1.33.0 (#186)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-24 09:36:43 +02:00
renovate[bot]
311240e69d chore(docker): update docker:26.1-dind docker digest to a811114 2024-05-24 03:43:21 +00:00
renovate[bot]
03feac0b30 chore(deps): update dependency golangci/golangci-lint to v1.58.2 2024-05-20 09:31:10 +00:00
renovate[bot]
527d6b8428 chore(docker): update docker digests 2024-05-18 06:11:29 +00:00
51889e1102
chore: migrate to wp-plugin-go v3 (#181) 2024-05-17 21:55:16 +02:00
renovate[bot]
8761da6871 chore(docker): update docker.io/library/golang:1.22 docker digest to ab48cd7 2024-05-15 23:08:21 +00:00
renovate[bot]
053ab0fb69 chore(deps): update dependency golangci/golangci-lint to v1.58.1 2024-05-13 03:20:29 +00:00
37147a6a90
ci: fix golangci-lint deprecations 2024-05-12 11:08:24 +02:00
renovate[bot]
26460f0c9f chore(docker): update docker:26.1-dind docker digest to c890c32 2024-05-10 10:27:29 +00:00
renovate[bot]
d5f2c72a18 chore(docker): update docker.io/library/golang:1.22 docker digest to b1e05e2 2024-05-08 03:12:39 +00:00
6964a133e8
fix: check is cmd is nil before execution (#176) 2024-05-07 11:57:26 +02:00
6087e0e1e4
cleanup import 2024-05-06 21:26:56 +02:00
757d2804ea
refactor: switch to plugin Cmd and add tests (#175) 2024-05-06 20:29:51 +02:00
renovate[bot]
3e74ff0c22 chore(deps): update dependency golangci/golangci-lint to v1.58.0 2024-05-06 04:23:30 +00:00
renovate[bot]
6c91855a4d
fix(deps): update module golang.org/x/sys to v0.20.0 (#171)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-05 13:03:59 +02:00
77beefbc24
docs: hide system flags and refactor generator (#169) 2024-05-05 13:03:50 +02:00
renovate[bot]
43c2e2074c chore(docker): update docker:26.1-dind docker digest to 56e2c52 2024-05-03 03:51:41 +00:00
renovate[bot]
0e549d8232
fix(deps): update module github.com/urfave/cli/v2 to v2.27.2 (#166)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 10:27:28 +02:00
renovate[bot]
2e429e38e4 chore(docker): update docker:26.1-dind docker digest to 66183ea 2024-04-27 04:45:16 +00:00
renovate[bot]
bee53eb3bb chore(docker): update docker:26.1-dind docker digest to 308c63f 2024-04-26 04:32:39 +00:00
renovate[bot]
6b9393a6e9
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v4.0.2 (#163)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-25 13:17:48 +02:00
renovate[bot]
37476ba4cc chore(docker): update docker.io/library/golang:1.22 docker digest to d5302d4 2024-04-25 03:50:53 +00:00
renovate[bot]
46cfd69d5f
chore(deps): update docker docker tag to v26.1 (#161)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-24 09:23:50 +02:00
renovate[bot]
b8749c1199
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v4.0.1 (#160)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-22 20:46:26 +02:00
renovate[bot]
9ed4065964
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.7.1 (#159)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-22 12:38:35 +02:00
renovate[bot]
fe25250ffb chore(docker): update docker:26.0-dind docker digest to c8d3a4b 2024-04-21 03:42:04 +00:00
renovate[bot]
c2804f8b28
chore(deps): update dependency docker/buildx to v0.14.0 (#156)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-20 14:21:42 +02:00
renovate[bot]
9d102b7cfd chore(docker): update docker:26.0-dind docker digest to 12b3a58 2024-04-19 03:36:01 +00:00
renovate[bot]
c033c7f497 chore(docker): update docker:26.0-dind docker digest to a2d55c6 2024-04-13 03:13:32 +00:00
renovate[bot]
6f2836570d chore(docker): update docker.io/library/golang:1.22 docker digest to 450e382 2024-04-11 08:52:29 +00:00
renovate[bot]
227a4275de
fix(deps): update module golang.org/x/sys to v0.19.0 (#153)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-05 08:55:17 +02:00
renovate[bot]
93fd442469 chore(docker): update docker.io/library/golang:1.22 docker digest to c4fb952 2024-04-04 03:12:40 +00:00
renovate[bot]
c55260ce5f chore(docker): update docker:26.0-dind docker digest to 7ff986c 2024-04-03 03:42:44 +00:00
renovate[bot]
013cd7453f chore(deps): update dependency golangci/golangci-lint to v1.57.2 2024-04-01 04:02:36 +00:00
renovate[bot]
d4de895786
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v4 (#149)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 08:43:04 +01:00
renovate[bot]
a1e6014fa4 chore(docker): update docker:26.0-dind docker digest to 016c45d 2024-03-26 12:23:30 +00:00
renovate[bot]
5242129034
fix(deps): update module github.com/cenkalti/backoff/v4 to v4.3.0 (#148)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-26 08:32:08 +01:00
renovate[bot]
d8d3c66457 chore(deps): update dependency golangci/golangci-lint to v1.57.1 2024-03-25 03:52:03 +00:00
renovate[bot]
60292346c4 chore(docker): update docker:26.0-dind docker digest to 645776c 2024-03-22 03:11:08 +00:00
renovate[bot]
0143851c2a
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.7.0 (#136)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-21 08:52:15 +01:00
renovate[bot]
618e3a6c13
chore(deps): update docker docker tag to v26 (#144)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-21 08:52:05 +01:00
renovate[bot]
2ac334c35c chore(docker): update docker:25.0-dind docker digest to b1ac36e 2024-03-21 04:29:51 +00:00
renovate[bot]
e43a5b4e71 chore(docker): update docker:25.0-dind docker digest to 96637a2 2024-03-20 03:49:57 +00:00
renovate[bot]
e941a5e280 chore(docker): update docker:25.0-dind docker digest to 92efb5a 2024-03-19 08:40:04 +00:00
renovate[bot]
d12afa90a9 chore(docker): update docker:25.0-dind docker digest to 19a2619 2024-03-17 05:00:55 +00:00
renovate[bot]
bad6e60fc0 chore(docker): update docker:25.0-dind docker digest to 93529df 2024-03-15 06:30:23 +00:00
renovate[bot]
7275d38204
chore(deps): update dependency docker/buildx to v0.13.1 (#137)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-13 08:34:01 +01:00
renovate[bot]
e125a06ad5 chore(docker): update docker.io/library/golang:1.22 docker digest to 0b55ab8 2024-03-13 07:11:42 +00:00
32b8862350
cleanup docs and examples 2024-03-12 20:43:33 +01:00
renovate[bot]
364568e8b0 chore(docker): update docker:25.0-dind docker digest to 0b0e8ca 2024-03-08 08:02:07 +00:00
renovate[bot]
40bb7451e5
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.6.1 (#134)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-07 21:26:37 +01:00
renovate[bot]
bed66837a1
chore(deps): update dependency docker/buildx to v0.13.0 (#132)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-06 14:42:34 +01:00
renovate[bot]
9114f75b7f
fix(deps): update module golang.org/x/sys to v0.18.0 (#131)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-06 14:42:27 +01:00
renovate[bot]
1abc453f21 chore(docker): update docker.io/library/golang:1.22 docker digest to 34ce21a 2024-03-06 05:04:15 +00:00
renovate[bot]
85629e1232 chore(docker): update docker:25.0-dind docker digest to 0d70c54 2024-02-28 06:47:22 +00:00
renovate[bot]
5a3a888da4 chore(deps): update dependency golangci/golangci-lint to v1.56.2 2024-02-19 07:46:00 +00:00
renovate[bot]
a3051884d6 chore(docker): update docker:25.0-dind docker digest to f837abe 2024-02-19 04:14:01 +00:00
renovate[bot]
2007cebab9 chore(docker): update docker:25.0-dind docker digest to 28940f5 2024-02-18 04:59:58 +00:00
renovate[bot]
9e41dbf10a chore(docker): update docker digests 2024-02-16 03:24:35 +00:00
ac1e4bcf84
[skip ci] revert renovate automerge config 2024-02-15 12:19:25 +01:00
renovate[bot]
af29e5e5e5
chore(deps): update dependency golangci/golangci-lint to v1.56.1 (#125)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-02-12 09:25:35 +01:00
renovate[bot]
039ac80ade
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v3.0.1 (#124)
* chore(docker): update docker:25.0-dind docker digest to 915cd16

* chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v3.0.1

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-10 12:03:31 +01:00
renovate[bot]
4d87c400ae
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.6.0 (#123)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-09 22:07:52 +01:00
renovate[bot]
73fe540714
fix(deps): update module golang.org/x/sys to v0.17.0 (#122)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-07 22:36:13 +01:00
renovate[bot]
acc86f83e1
chore(deps): update docker.io/library/golang docker tag to v1.22 (#120)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-02-07 22:33:00 +01:00
f0affc7e82
harmonize container image refs and use fqin 2024-02-07 09:40:36 +01:00
0ecd8eaef7
run ci on renovate auto branches 2024-02-07 09:10:07 +01:00
7928e6d890
ci: enable ci run on renovate branches 2024-02-05 08:58:25 +01:00
renovate[bot]
0109494003
fix(deps): update module github.com/rs/zerolog to v1.32.0 (#118)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-05 08:45:34 +01:00
renovate[bot]
3e637dca82 chore(docker): update docker digests 2024-02-05 06:32:52 +00:00
renovate[bot]
406b5b7e9b chore(deps): update dependency mvdan/gofumpt to v0.6.0 2024-01-30 21:28:36 +00:00
renovate[bot]
7578930b07 chore(docker): update docker:25.0-dind docker digest to 91c7180 2024-01-29 15:30:51 +00:00
renovate[bot]
393f58c283 chore(docker): update docker digests 2024-01-26 14:44:50 +00:00
renovate[bot]
da488f3cd1 chore(docker): update docker:25.0-dind docker digest to 90e4d6d 2024-01-23 09:17:06 +00:00
renovate[bot]
f4f20e2ad0
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v3 (#113)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-22 11:28:52 +01:00
renovate[bot]
6fe5b8ae2b
chore(deps): update docker docker tag to v25 (#112)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-20 15:11:05 +01:00
renovate[bot]
daf4eabc0d chore(docker): update docker:24.0-dind docker digest to 95443f4 2024-01-19 16:42:02 +00:00
renovate[bot]
6e2edf5d8f chore(docker): update docker:24.0-dind docker digest to 6116ec6 2024-01-19 06:14:35 +00:00
renovate[bot]
12766489aa chore(docker): update golang:1.21 docker digest to 5f5d61d 2024-01-17 12:47:38 +00:00
renovate[bot]
02eb1f6b02
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v2.0.2 (#108)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-17 10:15:09 +01:00
renovate[bot]
f18e09f6db chore(docker): update docker:24.0-dind docker digest to b42e6e3 2024-01-14 09:09:20 +00:00
renovate[bot]
e13317cea2 chore(docker): update docker:24.0-dind docker digest to d427455 2024-01-14 03:22:27 +00:00
renovate[bot]
dd91bae1d7 chore(docker): update docker:24.0-dind docker digest to a293bf8 2024-01-13 09:45:19 +00:00
renovate[bot]
4397e10917
chore(deps): update dependency docker/buildx to v0.12.1 (#104)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 08:29:54 +01:00
renovate[bot]
04bb458b9d chore(docker): update golang:1.21 docker digest to 6fbd2d3 2024-01-12 02:13:07 +00:00
renovate[bot]
b21bac3445 chore(docker): update golang:1.21 docker digest to 21260a4 2024-01-11 16:08:49 +00:00
renovate[bot]
58efa02594 chore(docker): update golang:1.21 docker digest to ffbb0b8 2024-01-11 03:29:26 +00:00
renovate[bot]
952ddd1343 chore(docker): update docker digests 2024-01-10 03:33:44 +00:00
renovate[bot]
316a28007c chore(docker): update docker:24.0-dind docker digest to 0361a91 2024-01-09 07:12:55 +00:00
renovate[bot]
9f93efbac8 chore(docker): update docker:24.0-dind docker digest to eb59696 2024-01-08 13:59:42 +00:00
eed177e79c
fix license desc in docs 2024-01-06 14:45:58 +01:00
renovate[bot]
640295de76 chore(docker): update docker:24.0-dind docker digest to 2afebd1 2024-01-05 16:50:14 +00:00
renovate[bot]
8d74b2194d
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v2.0.1 (#96)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-05 13:22:38 +01:00
renovate[bot]
900acf8fa3
fix(deps): update module golang.org/x/sys to v0.16.0 (#95)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-04 20:34:00 +01:00
efdbce96cd
docs: fix default value property in data file 2024-01-03 23:26:12 +01:00
7cb1fdfd01
chore: cleanup docs and use cmd trace from plugin lib (#94) 2024-01-03 21:23:07 +01:00
renovate[bot]
a6c41b061c
fix(deps): update module github.com/urfave/cli/v2 to v2.27.1 (#92)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-01 16:22:03 +01:00
bca6cd86bb
use list style synatx and cleanup (#91) 2023-12-23 23:44:35 +01:00
renovate[bot]
207514c780
fix(deps): update module github.com/thegeeklab/wp-plugin-go to v1.3.0 (#90)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-21 13:41:45 +01:00
renovate[bot]
8676df453f chore(docker): update golang:1.21 docker digest to 672a228 2023-12-21 06:23:45 +00:00
renovate[bot]
c668be61db chore(docker): update golang:1.21 docker digest to fb02af5 2023-12-20 20:01:38 +00:00
renovate[bot]
69fe8d2b95 chore(docker): update golang:1.21 docker digest to 1a9d253 2023-12-20 07:48:33 +00:00
renovate[bot]
b6cb7f6ab3 chore(docker): update golang:1.21 docker digest to b172263 2023-12-19 15:59:09 +00:00
renovate[bot]
a3fd051a4d chore(docker): update docker:24.0-dind docker digest to 1b9844d 2023-12-16 04:36:40 +00:00
058a396567
ci: add missing test group 2023-12-15 22:34:44 +01:00
renovate[bot]
41b7479d2c chore(docker): update docker:24.0-dind docker digest to ae63bb7 2023-12-15 08:04:54 +00:00
renovate[bot]
4dece413dd chore(docker): update golang:1.21 docker digest to 2ff79bc 2023-12-13 04:09:53 +00:00
renovate[bot]
44a588db7c chore(docker): update golang:1.21 docker digest to ae34fbf 2023-12-09 09:36:22 +00:00
renovate[bot]
5940878fc4
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v2 (#81)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-07 08:35:38 +01:00
25 changed files with 1247 additions and 1080 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/dist
/release
/wp-docker-buildx*
docs/data/data-raw.yaml
coverage.out
CHANGELOG.md

View File

@ -23,7 +23,6 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exportloopref
- forcetypeassert
@ -37,12 +36,12 @@ linters:
- gocyclo
- godot
- godox
- goerr113
- err113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- mnd
- gomoddirectives
- gomodguard
- goprintffuncname

View File

@ -6,8 +6,8 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
dryrun:
image: quay.io/thegeeklab/wp-docker-buildx:1.1.4
- name: dryrun
image: quay.io/thegeeklab/wp-docker-buildx:4.0.2
settings:
containerfile: Containerfile.multiarch
dry_run: true
@ -19,9 +19,9 @@ steps:
when:
- event: [pull_request]
publish-dockerhub:
- name: publish-dockerhub
image: quay.io/thegeeklab/wp-docker-buildx:4.0.2
group: container
image: quay.io/thegeeklab/wp-docker-buildx:1.1.4
settings:
auto_tag: true
containerfile: Containerfile.multiarch
@ -40,9 +40,9 @@ steps:
branch:
- ${CI_REPO_DEFAULT_BRANCH}
publish-quay:
- name: publish-quay
image: quay.io/thegeeklab/wp-docker-buildx:4.0.2
group: container
image: quay.io/thegeeklab/wp-docker-buildx:1.1.4
settings:
auto_tag: true
containerfile: Containerfile.multiarch

View File

@ -6,26 +6,25 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
build:
image: docker.io/techknowlogick/xgo:go-1.21.x
- name: build
image: docker.io/techknowlogick/xgo:go-1.22.x
commands:
- ln -s $(pwd) /source
- make release
executable:
- name: executable
image: quay.io/thegeeklab/alpine-tools
commands:
- $(find dist/ -executable -type f -iname ${CI_REPO_NAME}-linux-amd64) --help
changelog:
- name: changelog
image: quay.io/thegeeklab/git-sv
commands:
- git fetch --depth=2147483647
- git sv current-version
- git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md
- cat CHANGELOG.md
publish-github:
- name: publish-github
image: docker.io/plugins/github-release
settings:
api_key:
@ -36,7 +35,7 @@ steps:
overwrite: true
title: ${CI_COMMIT_TAG}
when:
- event: [tag]
- event: [tag]
depends_on:
- test

View File

@ -6,26 +6,27 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
markdownlint:
- name: markdownlint
image: quay.io/thegeeklab/markdownlint-cli
group: test
commands:
- markdownlint 'README.md' 'CONTRIBUTING.md'
spellcheck:
- name: spellcheck
image: quay.io/thegeeklab/alpine-tools
group: test
commands:
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
- spellchecker --files 'docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
environment:
FORCE_COLOR: "true"
NPM_CONFIG_LOGLEVEL: "error"
link-validation:
- name: link-validation
image: docker.io/lycheeverse/lychee
group: test
commands:
- lychee --no-progress --format detailed _docs/content README.md
- lychee --no-progress --format detailed docs/content README.md
publish:
- name: publish
image: quay.io/thegeeklab/wp-git-action
settings:
action:
@ -36,19 +37,20 @@ steps:
message: "[skip ci] auto-update documentation"
netrc_password:
from_secret: github_token
pages_directory: _docs/
pages_directory: docs/
when:
- event: [push, manual]
branch:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success, failure]
pushrm-dockerhub:
- name: pushrm-dockerhub
image: docker.io/chko/docker-pushrm:1
secrets:
- source: docker_password
target: DOCKER_PASS
target: DOCKER_PASS
- source: docker_username
target: DOCKER_USER
target: DOCKER_USER
environment:
PUSHRM_FILE: README.md
PUSHRM_SHORT: Woodpecker CI plugin to build multiarch OCI images with buildx
@ -59,7 +61,7 @@ steps:
- ${CI_REPO_DEFAULT_BRANCH}
status: [success]
pushrm-quay:
- name: pushrm-quay
image: docker.io/chko/docker-pushrm:1
secrets:
- source: quay_token

View File

@ -8,7 +8,7 @@ when:
runs_on: [success, failure]
steps:
matrix:
- name: matrix
image: quay.io/thegeeklab/wp-matrix
settings:
homeserver:

View File

@ -6,12 +6,12 @@ when:
- ${CI_REPO_DEFAULT_BRANCH}
steps:
lint:
image: docker.io/library/golang:1.21
- name: lint
image: docker.io/library/golang:1.22
commands:
- make lint
test:
image: docker.io/library/golang:1.21
- name: test
image: docker.io/library/golang:1.22
commands:
- make test

View File

@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.21@sha256:58e14a93348a3515c2becc54ebd35302128225169d166b7c6802451ab336c907 as build
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.22@sha256:f43c6f049f04cbbaeb28f0aad3eea15274a7d0a7899a617d0037aec48d7ab010 as build
ARG TARGETOS
ARG TARGETARCH
@ -8,7 +8,7 @@ WORKDIR /src
RUN make build
FROM docker:24.0-dind@sha256:c90e58d30700470fc59bdaaf802340fd25c1db628756d7bf74e100c566ba9589
FROM docker:26.1-dind@sha256:76ba10a4aed708c7b2db09d45740d711edf707f7368f6808bd32a53eaed33404
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
@ -22,7 +22,7 @@ ARG TARGETARCH
ARG BUILDX_VERSION
# renovate: datasource=github-releases depName=docker/buildx
ENV BUILDX_VERSION="${BUILDX_VERSION:-v0.12.0}"
ENV BUILDX_VERSION="${BUILDX_VERSION:-v0.14.1}"
ENV DOCKER_HOST=unix:///var/run/docker.sock

View File

@ -1,7 +1,7 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.5.0
GOFUMPT_PACKAGE_VERSION := v0.6.0
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.55.2
GOLANGCI_LINT_PACKAGE_VERSION := v1.59.0
EXECUTABLE := wp-docker-buildx
@ -19,8 +19,7 @@ GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(G
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GOTESTSUM_PACKAGE ?= gotest.tools/gotestsum@latest
GENERATE ?=
XGO_VERSION := go-1.21.x
XGO_VERSION := go-1.22.x
XGO_TARGETS ?= linux/amd64,linux/arm64
TARGETOS ?= linux
@ -28,7 +27,7 @@ TARGETARCH ?= amd64
ifneq ("$(TARGETVARIANT)","")
GOARM ?= $(subst v,,$(TARGETVARIANT))
endif
TAGS ?= netgo
TAGS ?= netgo,osusergo
ifndef VERSION
ifneq ($(CI_COMMIT_TAG),)
@ -65,7 +64,7 @@ lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
$(GO) generate $(PACKAGES)
.PHONY: test
test:

View File

@ -1,339 +0,0 @@
package main
import (
"github.com/thegeeklab/wp-docker-buildx/plugin"
"github.com/thegeeklab/wp-plugin-go/types"
"github.com/urfave/cli/v2"
)
// settingsFlags has the cli.Flags for the plugin.Settings.
//
//nolint:maintidx
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
EnvVars: []string{"PLUGIN_DRY_RUN"},
Usage: "disable docker push",
Destination: &settings.Dryrun,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mirror",
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
Usage: "registry mirror to pull images",
Destination: &settings.Daemon.Mirror,
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-driver",
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
Usage: "docker daemon storage driver",
Destination: &settings.Daemon.StorageDriver,
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-path",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
Usage: "docker daemon storage path",
Value: "/var/lib/docker",
Destination: &settings.Daemon.StoragePath,
Category: category,
},
&cli.StringFlag{
Name: "daemon.bip",
EnvVars: []string{"PLUGIN_BIP"},
Usage: "allow the docker daemon to bride ip address",
Destination: &settings.Daemon.Bip,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mtu",
EnvVars: []string{"PLUGIN_MTU"},
Usage: "docker daemon custom mtu setting",
Destination: &settings.Daemon.MTU,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
Usage: "custom docker daemon dns server",
Destination: &settings.Daemon.DNS,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
Usage: "custom docker daemon dns search domain",
Destination: &settings.Daemon.DNSSearch,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.insecure",
EnvVars: []string{"PLUGIN_INSECURE"},
Usage: "allow the docker daemon to use insecure registries",
Value: false,
Destination: &settings.Daemon.Insecure,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.ipv6",
EnvVars: []string{"PLUGIN_IPV6"},
Usage: "enable docker daemon IPv6 support",
Value: false,
Destination: &settings.Daemon.IPv6,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.experimental",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
Usage: "enable docker daemon experimental mode",
Value: false,
Destination: &settings.Daemon.Experimental,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.debug",
EnvVars: []string{"PLUGIN_DEBUG"},
Usage: "enable verbose debug mode for the docker daemon",
Value: false,
Destination: &settings.Daemon.Debug,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.off",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
Usage: "disable the startup of the docker daemon",
Value: false,
Destination: &settings.Daemon.Disabled,
Category: category,
},
&cli.StringFlag{
Name: "daemon.buildkit-config",
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
Usage: "content of the docker buildkit toml config",
Destination: &settings.Daemon.BuildkitConfig,
Category: category,
},
&cli.StringFlag{
Name: "daemon.max-concurrent-uploads",
EnvVars: []string{"PLUGIN_MAX_CONCURRENT_UPLOADS"},
Usage: "max concurrent uploads for each push",
Destination: &settings.Daemon.MaxConcurrentUploads,
Category: category,
},
&cli.StringFlag{
Name: "containerfile",
EnvVars: []string{"PLUGIN_CONTAINERFILE"},
Usage: "containerfile to use for the image build",
Value: "Containerfile",
Destination: &settings.Build.Containerfile,
Category: category,
},
&cli.StringFlag{
Name: "context",
EnvVars: []string{"PLUGIN_CONTEXT"},
Usage: "path of the build context",
Value: ".",
Destination: &settings.Build.Context,
Category: category,
},
&cli.StringSliceFlag{
Name: "named-context",
EnvVars: []string{"PLUGIN_NAMED_CONTEXT"},
Usage: "additional named build context",
Destination: &settings.Build.NamedContext,
Category: category,
},
&cli.StringSliceFlag{
Name: "tags",
EnvVars: []string{"PLUGIN_TAG", "PLUGIN_TAGS"},
Usage: "repository tags to use for the image",
FilePath: ".tags",
Destination: &settings.Build.Tags,
Category: category,
},
&cli.BoolFlag{
Name: "tags.auto",
EnvVars: []string{"PLUGIN_DEFAULT_TAGS", "PLUGIN_AUTO_TAG"},
Usage: "generate tag names automatically based on git branch and git tag",
Value: false,
Destination: &settings.Build.TagsAuto,
Category: category,
},
&cli.StringFlag{
Name: "tags.suffix",
EnvVars: []string{"PLUGIN_DEFAULT_SUFFIX", "PLUGIN_AUTO_TAG_SUFFIX"},
Usage: "generate tag names with the given suffix",
Destination: &settings.Build.TagsSuffix,
Category: category,
},
&cli.StringSliceFlag{
Name: "extra.tags",
EnvVars: []string{"PLUGIN_EXTRA_TAGS"},
Usage: "additional tags to use for the image including registry",
FilePath: ".extratags",
Destination: &settings.Build.ExtraTags,
Category: category,
},
&cli.StringSliceFlag{
Name: "args",
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
Usage: "custom build arguments for the build",
Destination: &settings.Build.Args,
Category: category,
},
&cli.StringSliceFlag{
Name: "args-from-env",
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
Usage: "forward environment variables as custom arguments to the build",
Destination: &settings.Build.ArgsEnv,
Category: category,
},
&cli.BoolFlag{
Name: "quiet",
EnvVars: []string{"PLUGIN_QUIET"},
Usage: "enable suppression of the build output",
Value: false,
Destination: &settings.Build.Quiet,
Category: category,
},
&cli.StringFlag{
Name: "output",
EnvVars: []string{"PLUGIN_OUTPUT"},
Usage: "export action for the build result",
Destination: &settings.Build.Output,
Category: category,
},
&cli.StringFlag{
Name: "target",
EnvVars: []string{"PLUGIN_TARGET"},
Usage: "build target to use",
Destination: &settings.Build.Target,
Category: category,
},
&cli.GenericFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "images to consider as cache sources",
Value: &types.StringSliceFlag{},
Category: category,
},
&cli.StringFlag{
Name: "cache-to",
EnvVars: []string{"PLUGIN_CACHE_TO"},
Usage: "cache destination for the build cache",
Destination: &settings.Build.CacheTo,
Category: category,
},
&cli.BoolFlag{
Name: "pull-image",
EnvVars: []string{"PLUGIN_PULL_IMAGE"},
Usage: "enforce to pull base image at build time",
Value: true,
Destination: &settings.Build.Pull,
Category: category,
},
&cli.BoolFlag{
Name: "compress",
EnvVars: []string{"PLUGIN_COMPRESS"},
Usage: "enable compression of the build context using gzip",
Value: false,
Destination: &settings.Build.Compress,
Category: category,
},
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"PLUGIN_REPO"},
Usage: "repository name for the image",
Destination: &settings.Build.Repo,
Category: category,
},
&cli.StringFlag{
Name: "docker.registry",
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
Usage: "docker registry to authenticate with",
Value: "https://index.docker.io/v1/",
Destination: &settings.Login.Registry,
Category: category,
},
&cli.StringFlag{
Name: "docker.username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
Usage: "username for registry authentication",
Destination: &settings.Login.Username,
Category: category,
},
&cli.StringFlag{
Name: "docker.password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
Usage: "password for registry authentication",
Destination: &settings.Login.Password,
Category: category,
},
&cli.StringFlag{
Name: "docker.email",
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
Usage: "email address for registry authentication",
Destination: &settings.Login.Email,
Category: category,
},
&cli.StringFlag{
Name: "docker.config",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
Usage: "content of the docker daemon json config",
Destination: &settings.Login.Config,
Category: category,
},
&cli.BoolFlag{
Name: "no-cache",
EnvVars: []string{"PLUGIN_NO_CACHE"},
Usage: "disable the usage of cached intermediate containers",
Value: false,
Destination: &settings.Build.NoCache,
Category: category,
},
&cli.StringSliceFlag{
Name: "add-host",
EnvVars: []string{"PLUGIN_ADD_HOST"},
Usage: "additional host:ip mapping",
Destination: &settings.Build.AddHost,
Category: category,
},
&cli.StringSliceFlag{
Name: "platforms",
EnvVars: []string{"PLUGIN_PLATFORMS"},
Usage: "target platform for build",
Destination: &settings.Build.Platforms,
Category: category,
},
&cli.StringSliceFlag{
Name: "labels",
EnvVars: []string{"PLUGIN_LABELS"},
Usage: "labels to add to image",
Destination: &settings.Build.Labels,
Category: category,
},
&cli.StringFlag{
Name: "provenance",
EnvVars: []string{"PLUGIN_PROVENANCE"},
Usage: "generates provenance attestation for the build",
Destination: &settings.Build.Provenance,
Category: category,
},
&cli.StringFlag{
Name: "sbom",
EnvVars: []string{"PLUGIN_SBOM"},
Usage: "generates sbom attestation for the build",
Destination: &settings.Build.SBOM,
Category: category,
},
&cli.GenericFlag{
Name: "secrets",
EnvVars: []string{"PLUGIN_SECRETS"},
Usage: "exposes secrets to the build",
Value: &types.StringSliceFlag{},
Category: category,
},
}
}

View File

@ -1,11 +1,7 @@
package main
import (
"fmt"
"github.com/thegeeklab/wp-docker-buildx/plugin"
wp "github.com/thegeeklab/wp-plugin-go/plugin"
)
//nolint:gochecknoglobals
@ -15,14 +11,5 @@ var (
)
func main() {
settings := &plugin.Settings{}
options := wp.Options{
Name: "wp-docker-buildx",
Description: "Build multiarch OCI images with buildx",
Version: BuildVersion,
VersionMetadata: fmt.Sprintf("date=%s", BuildDate),
Flags: settingsFlags(settings, wp.FlagsPluginCategory),
}
plugin.New(options, settings).Run()
plugin.New(nil, BuildVersion, BuildDate).Run()
}

123
docker/daemon.go Normal file
View File

@ -0,0 +1,123 @@
package docker
import (
"os"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
"github.com/urfave/cli/v2"
)
const dockerdBin = "/usr/local/bin/dockerd"
// 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
BuildkitConfigFile string // Docker buildkit config file
MaxConcurrentUploads string // Docker daemon max concurrent uploads
}
// helper function to create the docker daemon command.
func (d *Daemon) Start() *plugin_exec.Cmd {
args := []string{
"--data-root", d.StoragePath,
"--host=unix:///var/run/docker.sock",
}
if d.StorageDriver != "" {
args = append(args, "-s", d.StorageDriver)
}
if d.Insecure && d.Registry != "" {
args = append(args, "--insecure-registry", d.Registry)
}
if d.IPv6 {
args = append(args, "--ipv6")
}
if d.Mirror != "" {
args = append(args, "--registry-mirror", d.Mirror)
}
if d.Bip != "" {
args = append(args, "--bip", d.Bip)
}
for _, dns := range d.DNS.Value() {
args = append(args, "--dns", dns)
}
for _, dnsSearch := range d.DNSSearch.Value() {
args = append(args, "--dns-search", dnsSearch)
}
if d.MTU != "" {
args = append(args, "--mtu", d.MTU)
}
if d.Experimental {
args = append(args, "--experimental")
}
if d.MaxConcurrentUploads != "" {
args = append(args, "--max-concurrent-uploads", d.MaxConcurrentUploads)
}
cmd := plugin_exec.Command(dockerdBin, args...)
if d.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
return cmd
}
func (d *Daemon) CreateBuilder() *plugin_exec.Cmd {
args := []string{
"buildx",
"create",
"--use",
}
if d.BuildkitConfigFile != "" {
args = append(args, "--config", d.BuildkitConfigFile)
}
cmd := plugin_exec.Command(dockerBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
func (d *Daemon) ListBuilder() *plugin_exec.Cmd {
cmd := plugin_exec.Command(dockerBin, "buildx", "ls")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
func (d *Daemon) StartCoreDNS() *plugin_exec.Cmd {
cmd := plugin_exec.Command("coredns", "-conf", "/etc/coredns/Corefile")
if d.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
}
return cmd
}

236
docker/docker.go Normal file
View File

@ -0,0 +1,236 @@
package docker
import (
"fmt"
"os"
"strings"
"time"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
"github.com/urfave/cli/v2"
)
const dockerBin = "/usr/local/bin/docker"
// Login defines Docker login parameters.
type Registry struct {
Address string // Docker registry address
Username string // Docker registry username
Password string // Docker registry password
Email string // Docker registry email
Config string // Docker Auth Config
}
// Build defines Docker build parameters.
type Build struct {
Ref string // Git commit ref
Branch string // Git repository branch
Containerfile string // Docker build Containerfile
Context string // Docker build context
TagsAuto bool // Docker build auto tag
TagsSuffix string // Docker build tags with suffix
Tags cli.StringSlice // Docker build tags
ExtraTags cli.StringSlice // Docker build tags including registry
Platforms cli.StringSlice // Docker build target platforms
Args cli.StringSlice // Docker build args
ArgsEnv cli.StringSlice // Docker build args from env
Target string // Docker build target
Pull bool // Docker build pull
CacheFrom []string // Docker build cache-from
CacheTo string // Docker build cache-to
Compress bool // Docker build compress
Repo string // Docker build repository
NoCache bool // Docker build no-cache
AddHost cli.StringSlice // Docker build add-host
Quiet bool // Docker build quiet
Output string // Docker build output folder
NamedContext cli.StringSlice // Docker build named context
Labels cli.StringSlice // Docker build labels
Provenance string // Docker build provenance attestation
SBOM string // Docker build sbom attestation
Secrets []string // Docker build secrets
Dryrun bool // Docker build dryrun
}
// helper function to create the docker login command.
func (r *Registry) Login() *plugin_exec.Cmd {
args := []string{
"login",
"-u", r.Username,
"-p", r.Password,
}
if r.Email != "" {
args = append(args, "-e", r.Email)
}
args = append(args, r.Address)
cmd := plugin_exec.Command(dockerBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
// helper function to create the docker info command.
func Version() *plugin_exec.Cmd {
cmd := plugin_exec.Command(dockerBin, "version")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
// helper function to create the docker info command.
func Info() *plugin_exec.Cmd {
cmd := plugin_exec.Command(dockerBin, "info")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
// helper function to create the docker build command.
func (b *Build) Run() *plugin_exec.Cmd {
args := []string{
"buildx",
"build",
"--rm=true",
"-f", b.Containerfile,
}
defaultBuildArgs := []string{
fmt.Sprintf("DOCKER_IMAGE_CREATED=%s", time.Now().Format(time.RFC3339)),
}
args = append(args, b.Context)
if !b.Dryrun && b.Output == "" && len(b.Tags.Value()) > 0 {
args = append(args, "--push")
}
if b.Compress {
args = append(args, "--compress")
}
if b.Pull {
args = append(args, "--pull=true")
}
if b.NoCache {
args = append(args, "--no-cache")
}
for _, arg := range b.CacheFrom {
args = append(args, "--cache-from", arg)
}
if b.CacheTo != "" {
args = append(args, "--cache-to", b.CacheTo)
}
for _, arg := range b.ArgsEnv.Value() {
b.addProxyValue(arg)
}
for _, arg := range append(defaultBuildArgs, b.Args.Value()...) {
args = append(args, "--build-arg", arg)
}
for _, host := range b.AddHost.Value() {
args = append(args, "--add-host", host)
}
if b.Target != "" {
args = append(args, "--target", b.Target)
}
if b.Quiet {
args = append(args, "--quiet")
}
if b.Output != "" {
args = append(args, "--output", b.Output)
}
for _, arg := range b.NamedContext.Value() {
args = append(args, "--build-context", arg)
}
if len(b.Platforms.Value()) > 0 {
args = append(args, "--platform", strings.Join(b.Platforms.Value(), ","))
}
for _, arg := range b.Tags.Value() {
args = append(args, "-t", fmt.Sprintf("%s:%s", b.Repo, arg))
}
for _, arg := range b.ExtraTags.Value() {
args = append(args, "-t", arg)
}
for _, arg := range b.Labels.Value() {
args = append(args, "--label", arg)
}
if b.Provenance != "" {
args = append(args, "--provenance", b.Provenance)
}
if b.SBOM != "" {
args = append(args, "--sbom", b.SBOM)
}
for _, secret := range b.Secrets {
args = append(args, "--secret", secret)
}
cmd := plugin_exec.Command(dockerBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd
}
// helper function to add proxy values from the environment.
func (b *Build) AddProxyBuildArgs() {
b.addProxyValue("http_proxy")
b.addProxyValue("https_proxy")
b.addProxyValue("no_proxy")
}
// helper function to add the upper and lower case version of a proxy value.
func (b *Build) addProxyValue(key string) {
value := b.getProxyValue(key)
if len(value) > 0 && !b.hasProxyBuildArg(key) {
b.Args = *cli.NewStringSlice(append(b.Args.Value(), fmt.Sprintf("%s=%s", key, value))...)
b.Args = *cli.NewStringSlice(append(b.Args.Value(), fmt.Sprintf("%s=%s", strings.ToUpper(key), value))...)
}
}
// helper function to get a proxy value from the environment.
//
// assumes that the upper and lower case versions of are the same.
func (b *Build) getProxyValue(key string) string {
value := os.Getenv(key)
if len(value) > 0 {
return value
}
return os.Getenv(strings.ToUpper(key))
}
// helper function that looks to see if a proxy value was set in the build args.
func (b *Build) hasProxyBuildArg(key string) bool {
keyUpper := strings.ToUpper(key)
for _, s := range b.Args.Value() {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) {
return true
}
}
return false
}

View File

@ -8,7 +8,7 @@ title: wp-docker-buildx
[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/wp-docker-buildx)](https://goreportcard.com/report/github.com/thegeeklab/wp-docker-buildx)
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/wp-docker-buildx)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/blob/main/LICENSE)
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/wp-docker-buildx)](https://github.com/thegeeklab/wp-docker-buildx/blob/main/LICENSE)
Woodpecker CI plugin to build multiarch OCI images with buildx.
@ -25,16 +25,13 @@ Be aware that the this plugin requires [privileged](https://woodpecker-ci.org/do
{{< /hint >}}
```yaml
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
settings:
username: octocat
password: secure
password: random-secret
repo: octocat/example
tags: latest
```
@ -56,12 +53,9 @@ If the created image is to be pushed to registries other than the default Docker
**GHCR:**
```yaml
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
settings:
registry: ghcr.io
@ -74,12 +68,9 @@ steps:
**AWS ECR:**
```yaml
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
environment:
AWS_ACCESS_KEY_ID:
@ -113,7 +104,7 @@ docker run --rm \
-e PLUGIN_TAG=latest \
-e PLUGIN_REPO=octocat/hello-world \
-e CI_COMMIT_SHA=00000000 \
-v $(pwd):/build:z \
-v $(pwd)/testdata:/build:z \
-w /build \
--privileged \
thegeeklab/wp-docker-buildx --dry-run

View File

@ -1,76 +1,49 @@
---
properties:
- name: dry_run
description: Disable docker push.
- name: add_host
description: |
Additional `host:ip` mapping.
type: list
required: false
- name: auto_tag
description: |
Generate tag names automatically based on git branch and git tag.
When this feature is enabled and the event type is `tag`, the plugin will automatically tag
the image using the standard semVer convention. For example:
- `1.0.0` produces docker tags `1`, `1.0`, `1.0.0`
- `1.0.0-rc.1` produces docker tags `1.0.0-rc.1`
When the event type is `push` and the target branch is your default branch, the plugin will
automatically tag the image as `latest`. All other event types and branches are ignored.
type: bool
defaultValue: false
required: false
- name: mirror
description: Use a registry mirror to pull images.
type: string
required: false
- name: storage_driver
description: The docker daemon storage driver.
type: string
required: false
- name: storage_path
description: The docker daemon storage path.
defaultValue: /var/lib/docker
- name: auto_tag_suffix
description: |
Generate tag names with the given suffix.
type: string
required: false
- name: bip
description: Allows the docker daemon to bride IP address.
description: |
Allow the docker daemon to bride IP address.
type: string
required: false
- name: mtu
description: A docker daemon custom MTU.
type: string
required: false
- name: custom_dns
description: Custom docker daemon DNS server.
- name: build_args
description: |
Custom build arguments for the build.
type: list
required: false
- name: custom_dns_search
description: Custom docker daemon DNS search domain.
- name: build_args_from_env
description: |
Forward environment variables as custom arguments to the build.
type: list
required: false
- name: insecure
description: Enable the usage of insecure registries.
type: bool
defaultValue: false
required: false
- name: ipv6
description: Enable docker daemon IPv6 support.
type: bool
defaultValue: false
required: false
- name: experimental
description: Enable docker daemon experimental mode.
type: bool
defaultValue: false
required: false
- name: debug
description: Enable verbose debug mode for the docker daemon.
type: string
defaultValue: false
required: false
- name: daemon_off
description: Disable the startup of the docker daemon.
type: string
defaultValue: false
required: false
- name: buildkit_config
description: |
Content of the docker buildkit toml [config](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md). Example:
@ -78,7 +51,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
settings:
repo: example/repo
buildkit_config: |
@ -87,83 +60,6 @@ properties:
insecure = true
```
type: string
defaultValue: false
required: false
- name: max_concurrent_uploads
description: |
By default the Docker daemon will push five layers of an image at a time. If you are on a low bandwidth connection this may cause
timeout issues and you may want to lower with this option.
type: string
required: false
- name: containerfile
description: Set the containerfile to use for the image build.
defaultValue: Containerfile
type: string
required: false
- name: context
description: Set the path of the build context to use.
defaultValue: .
type: string
required: false
- name: named_context
description: Set additional named [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (e.g., name=path).
type: list
required: false
- name: tags
description: Set repository tags to use for the image. Tags can also be loaded from a `.tags` file.
defaultValue: latest
type: list
required: false
- name: auto_tag
description: |
Generate tag names automatically based on git branch and git tag. When this feature is enabled and the event type is `tag`,
the plugin will automatically tag the image using the standard semVer convention. For example:
- `1.0.0` produces docker tags `1`, `1.0`, `1.0.0`
- `1.0.0-rc.1` produces docker tags `1.0.0-rc.1`
When the event type is `push` and the target branch is your default branch, the plugin will automatically tag the image
as `latest`. All other event types and branches are ignored.
defaultValue: false
type: bool
required: false
- name: auto_tag_suffix
description: Generate tag names with the given suffix.
type: string
required: false
- name: extra_tags
description: |
Set additional tags to be used for the image. Additional tags can also be loaded from an `.extratags` file. This function can be used
to push images to multiple registries at once. Therefore, it is necessary to use the `config` flag to provide a configuration file
that contains the authentication information for all used registries.
type: list
required: false
- name: build_args
description: Custom build arguments to pass to the build.
type: list
required: false
- name: build_args_from_env
description: Forward environment variables as custom arguments to the build.
type: list
required: false
- name: quiet
description: Enable suppression of the build output.
defaultValue: false
type: bool
required: false
- name: target
description: The docker build target.
type: string
required: false
- name: cache_from
@ -174,7 +70,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
settings:
repo: example/repo
cache_from:
@ -191,87 +87,219 @@ properties:
type: string
required: false
- name: pull_image
description: Enforce to pull the base image at build time.
defaultValue: true
- name: compress
description: |
Enable compression of the build context using gzip.
type: bool
defaultValue: false
required: false
- name: compress
description: Enable compression of the build context using gzip.
defaultValue: false
- name: config
description: |
Content of the docker daemon json config.
type: string
defaultValue: $DOCKER_PLUGIN_CONFIG
required: false
- name: containerfile
description: |
Containerfile to use for the image build.
type: string
defaultValue: "Containerfile"
required: false
- name: context
description: |
Path of the build context.
type: string
defaultValue: "."
required: false
- name: custom_dns
description: |
Custom docker daemon dns server.
type: list
required: false
- name: custom_dns_search
description: |
Custom docker daemon dns search domain.
type: list
required: false
- name: daemon_off
description: |
Disable the startup of the docker daemon.
type: bool
defaultValue: false
required: false
- name: debug
description: |
Enable verbose debug mode for the docker daemon.
type: bool
defaultValue: false
required: false
- name: dry_run
description: |
Disable docker push.
type: bool
defaultValue: false
required: false
- name: email
description: |
Email address for registry authentication.
type: string
defaultValue: $DOCKER_EMAIL
required: false
- name: experimental
description: |
Enable docker daemon experimental mode.
type: bool
defaultValue: false
required: false
- name: extra_tags
description: |
Additional tags to use for the image including registry.
Additional tags can also be loaded from an `.extratags` file. This function can be used to push
images to multiple registries at once. Therefore, it is necessary to use the `config` flag to
provide a configuration file that contains the authentication information for all used registries.
type: list
required: false
- name: insecure
description: |
Allow the docker daemon to use insecure registries.
type: bool
defaultValue: false
required: false
- name: insecure_skip_verify
description: |
Skip SSL verification.
type: bool
defaultValue: false
required: false
- name: ipv6
description: |
Enable docker daemon IPv6 support.
type: bool
defaultValue: false
required: false
- name: labels
description: |
Labels to add to image.
type: list
required: false
- name: log_level
description: |
Plugin log level.
type: string
defaultValue: "info"
required: false
- name: max_concurrent_uploads
description: |
Max concurrent uploads for each push.
By default the Docker daemon will push five layers of an image at a time. If you are on a low bandwidth connection this may cause
timeout issues and you may want to lower with this option.
type: string
required: false
- name: mirror
description: |
Registry mirror to pull images.
type: string
defaultValue: $DOCKER_PLUGIN_MIRROR
required: false
- name: mtu
description: |
Docker daemon custom MTU setting.
type: string
required: false
- name: named_context
description: |
Additional named [build contexts](https://docs.docker.com/engine/reference/commandline/buildx_build/#build-context) (format: `name=path`).
type: list
required: false
- name: no_cache
description: |
Disable the usage of cached intermediate containers.
type: bool
defaultValue: false
required: false
- name: output
description: |
[Export action](https://docs.docker.com/engine/reference/commandline/buildx_build/#output) for the build result
(format: `path` or `type=TYPE[,KEY=VALUE]`).
defaultValue: false
type: bool
required: false
- name: repo
description: |
Repository name for the image. If the image is to be pushed to registries other than the default DockerHub,
it is necessary to set `repo` as fully-qualified name.
type: string
required: false
- name: registry
description: Docker registry to upload images.
defaultValue: https://index.docker.io/v1/
type: string
required: false
- name: username
description: Username for authentication with the registry.
type: string
required: false
- name: password
description: Password for authentication with the registry.
description: |
Password for registry authentication.
type: string
required: false
- name: email
description: E-Mail address for authentication with the registry.
type: string
required: false
- name: config
description: Content of the docker daemon json config.
type: string
required: false
- name: no_cache
description: Disable the usage of cached intermediate containers.
defaultValue: false
type: string
required: false
- name: add_host
description: Additional `host:ip` mapping.
type: list
defaultValue: $DOCKER_PASSWORD
required: false
- name: platforms
description: Target platforms for build.
type: list
required: false
- name: labels
description: Labels to add to the image.
description: |
Target platform for build.
type: list
required: false
- name: provenance
description: Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`).
description: |
Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`).
type: string
required: false
- name: pull_image
description: |
Enforce to pull base image at build time.
type: bool
defaultValue: true
required: false
- name: quiet
description: |
Enable suppression of the build output.
type: bool
defaultValue: false
required: false
- name: registry
description: |
Docker registry to authenticate with.
type: string
defaultValue: "https://index.docker.io/v1/"
required: false
- name: repo
description: |
Repository name for the image.
If the image is to be pushed to registries other than the default DockerHub,
it is necessary to set `repo` as fully-qualified name.
type: string
required: false
- name: sbom
description: Generate [sbom](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest type=sbom`).
description: |
Generate [SBOM](https://docs.docker.com/build/attestations/sbom/) attestation for the build (shorthand for `--attest type=sbom`).
type: string
required: false
@ -283,7 +311,7 @@ properties:
```yaml
steps:
- name: Build
image: thegeeklab/wp-docker-buildx:23
image: quay.io/thegeeklab/wp-docker-buildx
privileged: true
environment:
SECURE_TOKEN:
@ -300,3 +328,37 @@ properties:
This should be used with caution and avoided whenever possible.
type: list
required: false
- name: storage_driver
description: |
Docker daemon storage driver.
type: string
required: false
- name: storage_path
description: |
Docker daemon storage path.
type: string
defaultValue: "/var/lib/docker"
required: false
- name: tags
description: |
Repository tags to use for the image.
Tags can also be loaded from a `.tags` file.
type: list
required: false
- name: target
description: |
Build target to use.
type: string
required: false
- name: username
description: |
Username for registry authentication.
type: string
defaultValue: $DOCKER_USERNAME
required: false

28
go.mod
View File

@ -1,22 +1,32 @@
module github.com/thegeeklab/wp-docker-buildx
go 1.21
go 1.22
require (
github.com/cenkalti/backoff/v4 v4.2.1
github.com/rs/zerolog v1.31.0
github.com/thegeeklab/wp-plugin-go v1.2.0
github.com/urfave/cli/v2 v2.26.0
golang.org/x/sys v0.15.0
github.com/cenkalti/backoff/v4 v4.3.0
github.com/rs/zerolog v1.33.0
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2
github.com/urfave/cli/v2 v2.27.2
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/net v0.19.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
)

97
go.sum
View File

@ -1,11 +1,25 @@
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA=
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
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/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4=
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
@ -13,22 +27,73 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/thegeeklab/wp-plugin-go v1.2.0 h1:ZvwfIIqT6UlclUhz3IYvHf+Jjam/orCaOgdTO+zbUiI=
github.com/thegeeklab/wp-plugin-go v1.2.0/go.mod h1:8DfPtNMelj6rJxBru3r8CAE4PMg6HsbxcRuE2Mu1tpw=
github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2 h1:Mv5i8S1WY+BUNjTjX6lOnB3p8S9mvM+XwfY4R98gx0g=
github.com/thegeeklab/wp-plugin-go/v3 v3.0.2/go.mod h1:ij1iJcAVgzerBTqXnmq0bu1VA+hhVVwzXKqiqfoGjjg=
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

42
internal/docs/main.go Normal file
View File

@ -0,0 +1,42 @@
//go:build generate
// +build generate
package main
import (
"context"
"flag"
"net/http"
"os"
"time"
"github.com/thegeeklab/wp-docker-buildx/plugin"
plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs"
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
)
func main() {
tmpl := "https://raw.githubusercontent.com/thegeeklab/woodpecker-plugins/main/templates/docs-data.yaml.tmpl"
client := http.Client{
Timeout: 30 * time.Second,
}
p := plugin.New(nil)
out, err := plugin_template.Render(context.Background(), client, tmpl, plugin_docs.GetTemplateData(p.App))
if err != nil {
panic(err)
}
outputFile := flag.String("output", "", "Output file path")
flag.Parse()
if *outputFile == "" {
panic("no output file specified")
}
err = os.WriteFile(*outputFile, []byte(out), 0o644)
if err != nil {
panic(err)
}
}

View File

@ -1,29 +0,0 @@
package plugin
import (
"io"
"os"
)
const (
dockerBin = "/usr/local/bin/docker"
dockerdBin = "/usr/local/bin/dockerd"
dockerHome = "/root/.docker/"
buildkitConfig = "/tmp/buildkit.toml"
)
func (p Plugin) startDaemon() {
cmd := commandDaemon(p.Settings.Daemon)
if p.Settings.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = io.Discard
cmd.Stderr = io.Discard
}
go func() {
trace(cmd)
_ = cmd.Run()
}()
}

View File

@ -1,267 +0,0 @@
package plugin
import (
"fmt"
"os"
"strings"
"time"
"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"
)
// helper function to create the docker login command.
func commandLogin(login Login) *execabs.Cmd {
if login.Email != "" {
return commandLoginEmail(login)
}
args := []string{
"login",
"-u", login.Username,
"-p", login.Password,
login.Registry,
}
return execabs.Command(
dockerBin, args...,
)
}
func commandLoginEmail(login Login) *execabs.Cmd {
args := []string{
"login",
"-u", login.Username,
"-p", login.Password,
"-e", login.Email,
login.Registry,
}
return execabs.Command(
dockerBin, args...,
)
}
// helper function to create the docker info command.
func commandVersion() *execabs.Cmd {
return execabs.Command(dockerBin, "version")
}
// helper function to create the docker info command.
func commandInfo() *execabs.Cmd {
return execabs.Command(dockerBin, "info")
}
func commandBuilder(daemon Daemon) *execabs.Cmd {
args := []string{
"buildx",
"create",
"--use",
}
if daemon.BuildkitConfig != "" {
args = append(args, "--config", buildkitConfig)
}
return execabs.Command(dockerBin, args...)
}
func commandBuildx() *execabs.Cmd {
return execabs.Command(dockerBin, "buildx", "ls")
}
// helper function to create the docker build command.
func commandBuild(build Build, dryrun bool) *execabs.Cmd {
args := []string{
"buildx",
"build",
"--rm=true",
"-f", build.Containerfile,
}
defaultBuildArgs := []string{
fmt.Sprintf("DOCKER_IMAGE_CREATED=%s", time.Now().Format(time.RFC3339)),
}
args = append(args, build.Context)
if !dryrun && build.Output == "" && len(build.Tags.Value()) > 0 {
args = append(args, "--push")
}
if build.Compress {
args = append(args, "--compress")
}
if build.Pull {
args = append(args, "--pull=true")
}
if build.NoCache {
args = append(args, "--no-cache")
}
for _, arg := range build.CacheFrom {
args = append(args, "--cache-from", arg)
}
if build.CacheTo != "" {
args = append(args, "--cache-to", build.CacheTo)
}
for _, arg := range build.ArgsEnv.Value() {
addProxyValue(&build, arg)
}
for _, arg := range append(defaultBuildArgs, build.Args.Value()...) {
args = append(args, "--build-arg", arg)
}
for _, host := range build.AddHost.Value() {
args = append(args, "--add-host", host)
}
if build.Target != "" {
args = append(args, "--target", build.Target)
}
if build.Quiet {
args = append(args, "--quiet")
}
if build.Output != "" {
args = append(args, "--output", build.Output)
}
for _, arg := range build.NamedContext.Value() {
args = append(args, "--build-context", arg)
}
if len(build.Platforms.Value()) > 0 {
args = append(args, "--platform", strings.Join(build.Platforms.Value(), ","))
}
for _, arg := range build.Tags.Value() {
args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg))
}
for _, arg := range build.ExtraTags.Value() {
args = append(args, "-t", arg)
}
for _, arg := range build.Labels.Value() {
args = append(args, "--label", arg)
}
if build.Provenance != "" {
args = append(args, "--provenance", build.Provenance)
}
if build.SBOM != "" {
args = append(args, "--sbom", build.SBOM)
}
for _, secret := range build.Secrets {
args = append(args, "--secret", secret)
}
return execabs.Command(dockerBin, args...)
}
// helper function to add proxy values from the environment.
func addProxyBuildArgs(build *Build) {
addProxyValue(build, "http_proxy")
addProxyValue(build, "https_proxy")
addProxyValue(build, "no_proxy")
}
// helper function to add the upper and lower case version of a proxy value.
func addProxyValue(build *Build, key string) {
value := getProxyValue(key)
if len(value) > 0 && !hasProxyBuildArg(build, key) {
build.Args = *cli.NewStringSlice(append(build.Args.Value(), fmt.Sprintf("%s=%s", key, value))...)
build.Args = *cli.NewStringSlice(append(build.Args.Value(), fmt.Sprintf("%s=%s", strings.ToUpper(key), value))...)
}
}
// helper function to get a proxy value from the environment.
//
// assumes that the upper and lower case versions of are the same.
func getProxyValue(key string) string {
value := os.Getenv(key)
if len(value) > 0 {
return value
}
return os.Getenv(strings.ToUpper(key))
}
// helper function that looks to see if a proxy value was set in the build args.
func hasProxyBuildArg(build *Build, key string) bool {
keyUpper := strings.ToUpper(key)
for _, s := range build.Args.Value() {
if strings.HasPrefix(s, key) || strings.HasPrefix(s, keyUpper) {
return true
}
}
return false
}
// helper function to create the docker daemon command.
func commandDaemon(daemon Daemon) *execabs.Cmd {
args := []string{
"--data-root", daemon.StoragePath,
"--host=unix:///var/run/docker.sock",
}
if daemon.StorageDriver != "" {
args = append(args, "-s", daemon.StorageDriver)
}
if daemon.Insecure && daemon.Registry != "" {
args = append(args, "--insecure-registry", daemon.Registry)
}
if daemon.IPv6 {
args = append(args, "--ipv6")
}
if daemon.Mirror != "" {
args = append(args, "--registry-mirror", daemon.Mirror)
}
if daemon.Bip != "" {
args = append(args, "--bip", daemon.Bip)
}
for _, dns := range daemon.DNS.Value() {
args = append(args, "--dns", dns)
}
for _, dnsSearch := range daemon.DNSSearch.Value() {
args = append(args, "--dns-search", dnsSearch)
}
if daemon.MTU != "" {
args = append(args, "--mtu", daemon.MTU)
}
if daemon.Experimental {
args = append(args, "--experimental")
}
if daemon.MaxConcurrentUploads != "" {
args = append(args, "--max-concurrent-uploads", daemon.MaxConcurrentUploads)
}
return execabs.Command(dockerdBin, args...)
}
// trace writes each command to stdout with the command wrapped in an xml
// tag so that it can be extracted and displayed in the logs.
func trace(cmd *execabs.Cmd) {
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
}

View File

@ -5,15 +5,17 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"time"
"github.com/cenkalti/backoff/v4"
"github.com/rs/zerolog/log"
"github.com/thegeeklab/wp-plugin-go/tag"
"github.com/thegeeklab/wp-plugin-go/types"
"github.com/thegeeklab/wp-docker-buildx/docker"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
plugin_file "github.com/thegeeklab/wp-plugin-go/v3/file"
plugin_tag "github.com/thegeeklab/wp-plugin-go/v3/tag"
plugin_types "github.com/thegeeklab/wp-plugin-go/v3/types"
plugin_util "github.com/thegeeklab/wp-plugin-go/v3/util"
"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"
)
var ErrTypeAssertionFailed = errors.New("type assertion failed")
@ -46,15 +48,15 @@ func (p *Plugin) run(ctx context.Context) error {
func (p *Plugin) Validate() error {
p.Settings.Build.Branch = p.Metadata.Repository.Branch
p.Settings.Build.Ref = p.Metadata.Curr.Ref
p.Settings.Daemon.Registry = p.Settings.Login.Registry
p.Settings.Daemon.Registry = p.Settings.Registry.Address
if p.Settings.Build.TagsAuto {
// return true if tag event or default branch
if tag.IsTaggable(
if plugin_tag.IsTaggable(
p.Settings.Build.Ref,
p.Settings.Build.Branch,
) {
tag, err := tag.SemverTagSuffix(
tag, err := plugin_tag.SemverTagSuffix(
p.Settings.Build.Ref,
p.Settings.Build.TagsSuffix,
true,
@ -78,19 +80,28 @@ func (p *Plugin) Validate() error {
//
//nolint:gocognit
func (p *Plugin) Execute() error {
var err error
homeDir := plugin_util.GetUserHomeDir()
batchCmd := make([]*plugin_exec.Cmd, 0)
// start the Docker daemon server
//nolint: nestif
if !p.Settings.Daemon.Disabled {
// If no custom DNS value set start internal DNS server
if len(p.Settings.Daemon.DNS.Value()) == 0 {
ip, err := getContainerIP()
ip, err := GetContainerIP()
if err != nil {
log.Warn().Msgf("error detecting IP address: %v", err)
}
if ip != "" {
log.Debug().Msgf("discovered IP address: %v", ip)
p.startCoredns()
cmd := p.Settings.Daemon.StartCoreDNS()
go func() {
_ = cmd.Run()
}()
if err := p.Settings.Daemon.DNS.Set(ip); err != nil {
return fmt.Errorf("error setting daemon dns: %w", err)
@ -98,13 +109,16 @@ func (p *Plugin) Execute() error {
}
}
p.startDaemon()
cmd := p.Settings.Daemon.Start()
go func() {
_ = cmd.Run()
}()
}
// poll the docker daemon until it is started. This ensures the daemon is
// ready to accept connections before we proceed.
for i := 0; i < 15; i++ {
cmd := commandInfo()
cmd := docker.Info()
err := cmd.Run()
if err == nil {
@ -114,57 +128,40 @@ func (p *Plugin) Execute() error {
time.Sleep(time.Second * 1)
}
// Create Auth Config File
if p.Settings.Login.Config != "" {
if err := os.MkdirAll(dockerHome, strictFilePerm); err != nil {
return fmt.Errorf("failed to create docker home: %w", err)
}
path := filepath.Join(dockerHome, "config.json")
err := os.WriteFile(path, []byte(p.Settings.Login.Config), strictFilePerm)
if err != nil {
return fmt.Errorf("error writing config.json: %w", err)
if p.Settings.Registry.Config != "" {
if err := WriteDockerConf(homeDir, p.Settings.Registry.Config); err != nil {
return fmt.Errorf("error writing docker config: %w", err)
}
}
// login to the Docker registry
if p.Settings.Login.Password != "" {
cmd := commandLogin(p.Settings.Login)
err := cmd.Run()
if err != nil {
if p.Settings.Registry.Password != "" {
if err := p.Settings.Registry.Login().Run(); err != nil {
return fmt.Errorf("error authenticating: %w", err)
}
}
if p.Settings.Daemon.BuildkitConfig != "" {
err := os.WriteFile(buildkitConfig, []byte(p.Settings.Daemon.BuildkitConfig), strictFilePerm)
if err != nil {
return fmt.Errorf("error writing buildkit.toml: %w", err)
buildkitConf := p.Settings.BuildkitConfig
if buildkitConf != "" {
if p.Settings.Daemon.BuildkitConfigFile, err = plugin_file.WriteTmpFile("buildkit.toml", buildkitConf); err != nil {
return fmt.Errorf("error writing buildkit config: %w", err)
}
defer os.Remove(p.Settings.Daemon.BuildkitConfigFile)
}
switch {
case p.Settings.Login.Password != "":
case p.Settings.Registry.Password != "":
log.Info().Msgf("Detected registry credentials")
case p.Settings.Login.Config != "":
case p.Settings.Registry.Config != "":
log.Info().Msgf("Detected registry credentials file")
default:
log.Info().Msgf("Registry credentials or Docker config not provided. Guest mode enabled.")
}
// add proxy build args
addProxyBuildArgs(&p.Settings.Build)
p.Settings.Build.AddProxyBuildArgs()
backoffOps := func() error {
versionCmd := commandVersion() // docker version
versionCmd.Stdout = os.Stdout
versionCmd.Stderr = os.Stderr
trace(versionCmd)
return versionCmd.Run()
return docker.Version().Run()
}
backoffLog := func(err error, delay time.Duration) {
log.Error().Msgf("failed to run docker version command: %v: retry in %s", err, delay.Truncate(time.Second))
@ -174,20 +171,17 @@ func (p *Plugin) Execute() error {
return err
}
var batchCmd []*execabs.Cmd
batchCmd = append(batchCmd, commandInfo()) // docker info
batchCmd = append(batchCmd, commandBuilder(p.Settings.Daemon))
batchCmd = append(batchCmd, commandBuildx())
batchCmd = append(batchCmd, commandBuild(p.Settings.Build, p.Settings.Dryrun)) // docker build
batchCmd = append(batchCmd, docker.Info())
batchCmd = append(batchCmd, p.Settings.Daemon.CreateBuilder())
batchCmd = append(batchCmd, p.Settings.Daemon.ListBuilder())
batchCmd = append(batchCmd, p.Settings.Build.Run())
// execute all commands in batch mode.
for _, cmd := range batchCmd {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
trace(cmd)
if cmd == nil {
continue
}
err := cmd.Run()
if err != nil {
if err := cmd.Run(); err != nil {
return err
}
}
@ -196,14 +190,14 @@ func (p *Plugin) Execute() error {
}
func (p *Plugin) FlagsFromContext() error {
cacheFrom, ok := p.Context.Generic("cache-from").(*types.StringSliceFlag)
cacheFrom, ok := p.Context.Generic("cache-from").(*plugin_types.StringSliceFlag)
if !ok {
return fmt.Errorf("%w: failed to read cache-from input", ErrTypeAssertionFailed)
}
p.Settings.Build.CacheFrom = cacheFrom.Get()
secrets, ok := p.Context.Generic("secrets").(*types.StringSliceFlag)
secrets, ok := p.Context.Generic("secrets").(*plugin_types.StringSliceFlag)
if !ok {
return fmt.Errorf("%w: failed to read secrets input", ErrTypeAssertionFailed)
}

View File

@ -1,91 +1,394 @@
package plugin
import (
wp "github.com/thegeeklab/wp-plugin-go/plugin"
"fmt"
"github.com/thegeeklab/wp-docker-buildx/docker"
plugin_base "github.com/thegeeklab/wp-plugin-go/v3/plugin"
plugin_types "github.com/thegeeklab/wp-plugin-go/v3/types"
"github.com/urfave/cli/v2"
)
//go:generate go run ../internal/docs/main.go -output=../docs/data/data-raw.yaml
// Plugin implements provide the plugin.
type Plugin struct {
*wp.Plugin
*plugin_base.Plugin
Settings *Settings
}
// Settings for the Plugin.
type Settings struct {
Daemon Daemon
Login Login
Build Build
Dryrun bool
BuildkitConfig string
Daemon docker.Daemon
Registry docker.Registry
Build docker.Build
}
// 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
BuildkitConfig string // Docker buildkit config
MaxConcurrentUploads string
}
// Login defines Docker login parameters.
type Login struct {
Registry string // Docker registry address
Username string // Docker registry username
Password string // Docker registry password
Email string // Docker registry email
Config string // Docker Auth Config
}
// Build defines Docker build parameters.
type Build struct {
Ref string // Git commit ref
Branch string // Git repository branch
Containerfile string // Docker build Containerfile
Context string // Docker build context
TagsAuto bool // Docker build auto tag
TagsSuffix string // Docker build tags with suffix
Tags cli.StringSlice // Docker build tags
ExtraTags cli.StringSlice // Docker build tags including registry
Platforms cli.StringSlice // Docker build target platforms
Args cli.StringSlice // Docker build args
ArgsEnv cli.StringSlice // Docker build args from env
Target string // Docker build target
Pull bool // Docker build pull
CacheFrom []string // Docker build cache-from
CacheTo string // Docker build cache-to
Compress bool // Docker build compress
Repo string // Docker build repository
NoCache bool // Docker build no-cache
AddHost cli.StringSlice // Docker build add-host
Quiet bool // Docker build quiet
Output string // Docker build output folder
NamedContext cli.StringSlice // Docker build named context
Labels cli.StringSlice // Docker build labels
Provenance string // Docker build provenance attestation
SBOM string // Docker build sbom attestation
Secrets []string // Docker build secrets
}
func New(options wp.Options, settings *Settings) *Plugin {
p := &Plugin{}
if options.Execute == nil {
options.Execute = p.run
func New(e plugin_base.ExecuteFunc, build ...string) *Plugin {
p := &Plugin{
Settings: &Settings{},
}
p.Plugin = wp.New(options)
p.Settings = settings
options := plugin_base.Options{
Name: "wp-docker-buildx",
Description: "Build multiarch OCI images with buildx",
Flags: Flags(p.Settings, plugin_base.FlagsPluginCategory),
Execute: p.run,
HideWoodpeckerFlags: true,
}
if len(build) > 0 {
options.Version = build[0]
}
if len(build) > 1 {
options.VersionMetadata = fmt.Sprintf("date=%s", build[1])
}
if e != nil {
options.Execute = e
}
p.Plugin = plugin_base.New(options)
return p
}
// Flags returns a slice of CLI flags for the plugin.
//
//nolint:maintidx
func Flags(settings *Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
EnvVars: []string{"PLUGIN_DRY_RUN"},
Usage: "disable docker push",
Destination: &settings.Build.Dryrun,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mirror",
EnvVars: []string{"PLUGIN_MIRROR", "DOCKER_PLUGIN_MIRROR"},
Usage: "registry mirror to pull images",
Destination: &settings.Daemon.Mirror,
DefaultText: "$DOCKER_PLUGIN_MIRROR",
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-driver",
EnvVars: []string{"PLUGIN_STORAGE_DRIVER"},
Usage: "docker daemon storage driver",
Destination: &settings.Daemon.StorageDriver,
Category: category,
},
&cli.StringFlag{
Name: "daemon.storage-path",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
Usage: "docker daemon storage path",
Value: "/var/lib/docker",
Destination: &settings.Daemon.StoragePath,
Category: category,
},
&cli.StringFlag{
Name: "daemon.bip",
EnvVars: []string{"PLUGIN_BIP"},
Usage: "allow the docker daemon to bride IP address",
Destination: &settings.Daemon.Bip,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mtu",
EnvVars: []string{"PLUGIN_MTU"},
Usage: "docker daemon custom MTU setting",
Destination: &settings.Daemon.MTU,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
Usage: "custom docker daemon DNS server",
Destination: &settings.Daemon.DNS,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
Usage: "custom docker daemon DNS search domain",
Destination: &settings.Daemon.DNSSearch,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.insecure",
EnvVars: []string{"PLUGIN_INSECURE"},
Usage: "allow the docker daemon to use insecure registries",
Value: false,
Destination: &settings.Daemon.Insecure,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.ipv6",
EnvVars: []string{"PLUGIN_IPV6"},
Usage: "enable docker daemon IPv6 support",
Value: false,
Destination: &settings.Daemon.IPv6,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.experimental",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
Usage: "enable docker daemon experimental mode",
Value: false,
Destination: &settings.Daemon.Experimental,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.debug",
EnvVars: []string{"PLUGIN_DEBUG"},
Usage: "enable verbose debug mode for the docker daemon",
Value: false,
Destination: &settings.Daemon.Debug,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.off",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
Usage: "disable the startup of the docker daemon",
Value: false,
Destination: &settings.Daemon.Disabled,
Category: category,
},
&cli.StringFlag{
Name: "daemon.buildkit-config",
EnvVars: []string{"PLUGIN_BUILDKIT_CONFIG"},
Usage: "content of the docker buildkit toml config",
Destination: &settings.BuildkitConfig,
Category: category,
},
&cli.StringFlag{
Name: "daemon.max-concurrent-uploads",
EnvVars: []string{"PLUGIN_MAX_CONCURRENT_UPLOADS"},
Usage: "max concurrent uploads for each push",
Destination: &settings.Daemon.MaxConcurrentUploads,
Category: category,
},
&cli.StringFlag{
Name: "containerfile",
EnvVars: []string{"PLUGIN_CONTAINERFILE"},
Usage: "containerfile to use for the image build",
Value: "Containerfile",
Destination: &settings.Build.Containerfile,
Category: category,
},
&cli.StringFlag{
Name: "context",
EnvVars: []string{"PLUGIN_CONTEXT"},
Usage: "path of the build context",
Value: ".",
Destination: &settings.Build.Context,
Category: category,
},
&cli.StringSliceFlag{
Name: "named-context",
EnvVars: []string{"PLUGIN_NAMED_CONTEXT"},
Usage: "additional named build context",
Destination: &settings.Build.NamedContext,
Category: category,
},
&cli.StringSliceFlag{
Name: "tags",
EnvVars: []string{"PLUGIN_TAGS", "PLUGIN_TAG"},
Usage: "repository tags to use for the image",
FilePath: ".tags",
Destination: &settings.Build.Tags,
Category: category,
},
&cli.BoolFlag{
Name: "tags.auto",
EnvVars: []string{"PLUGIN_AUTO_TAG", "PLUGIN_DEFAULT_TAGS"},
Usage: "generate tag names automatically based on git branch and git tag",
Value: false,
Destination: &settings.Build.TagsAuto,
Category: category,
},
&cli.StringFlag{
Name: "tags.suffix",
EnvVars: []string{"PLUGIN_AUTO_TAG_SUFFIX", "PLUGIN_DEFAULT_SUFFIX"},
Usage: "generate tag names with the given suffix",
Destination: &settings.Build.TagsSuffix,
Category: category,
},
&cli.StringSliceFlag{
Name: "extra.tags",
EnvVars: []string{"PLUGIN_EXTRA_TAGS"},
Usage: "additional tags to use for the image including registry",
FilePath: ".extratags",
Destination: &settings.Build.ExtraTags,
Category: category,
},
&cli.StringSliceFlag{
Name: "args",
EnvVars: []string{"PLUGIN_BUILD_ARGS"},
Usage: "custom build arguments for the build",
Destination: &settings.Build.Args,
Category: category,
},
&cli.StringSliceFlag{
Name: "args-from-env",
EnvVars: []string{"PLUGIN_BUILD_ARGS_FROM_ENV"},
Usage: "forward environment variables as custom arguments to the build",
Destination: &settings.Build.ArgsEnv,
Category: category,
},
&cli.BoolFlag{
Name: "quiet",
EnvVars: []string{"PLUGIN_QUIET"},
Usage: "enable suppression of the build output",
Value: false,
Destination: &settings.Build.Quiet,
Category: category,
},
&cli.StringFlag{
Name: "output",
EnvVars: []string{"PLUGIN_OUTPUT"},
Usage: "export action for the build result",
Destination: &settings.Build.Output,
Category: category,
},
&cli.StringFlag{
Name: "target",
EnvVars: []string{"PLUGIN_TARGET"},
Usage: "build target to use",
Destination: &settings.Build.Target,
Category: category,
},
&cli.GenericFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "images to consider as cache sources",
Value: &plugin_types.StringSliceFlag{},
Category: category,
},
&cli.StringFlag{
Name: "cache-to",
EnvVars: []string{"PLUGIN_CACHE_TO"},
Usage: "cache destination for the build cache",
Destination: &settings.Build.CacheTo,
Category: category,
},
&cli.BoolFlag{
Name: "pull-image",
EnvVars: []string{"PLUGIN_PULL_IMAGE"},
Usage: "enforce to pull base image at build time",
Value: true,
Destination: &settings.Build.Pull,
Category: category,
},
&cli.BoolFlag{
Name: "compress",
EnvVars: []string{"PLUGIN_COMPRESS"},
Usage: "enable compression of the build context using gzip",
Value: false,
Destination: &settings.Build.Compress,
Category: category,
},
&cli.StringFlag{
Name: "repo",
EnvVars: []string{"PLUGIN_REPO"},
Usage: "repository name for the image",
Destination: &settings.Build.Repo,
Category: category,
},
&cli.StringFlag{
Name: "docker.registry",
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
Usage: "docker registry to authenticate with",
Value: "https://index.docker.io/v1/",
Destination: &settings.Registry.Address,
Category: category,
},
&cli.StringFlag{
Name: "docker.username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
Usage: "username for registry authentication",
Destination: &settings.Registry.Username,
DefaultText: "$DOCKER_USERNAME",
Category: category,
},
&cli.StringFlag{
Name: "docker.password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
Usage: "password for registry authentication",
Destination: &settings.Registry.Password,
DefaultText: "$DOCKER_PASSWORD",
Category: category,
},
&cli.StringFlag{
Name: "docker.email",
EnvVars: []string{"PLUGIN_EMAIL", "DOCKER_EMAIL"},
Usage: "email address for registry authentication",
Destination: &settings.Registry.Email,
DefaultText: "$DOCKER_EMAIL",
Category: category,
},
&cli.StringFlag{
Name: "docker.config",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
Usage: "content of the docker daemon json config",
Destination: &settings.Registry.Config,
DefaultText: "$DOCKER_PLUGIN_CONFIG",
Category: category,
},
&cli.BoolFlag{
Name: "no-cache",
EnvVars: []string{"PLUGIN_NO_CACHE"},
Usage: "disable the usage of cached intermediate containers",
Value: false,
Destination: &settings.Build.NoCache,
Category: category,
},
&cli.StringSliceFlag{
Name: "add-host",
EnvVars: []string{"PLUGIN_ADD_HOST"},
Usage: "additional `host:ip` mapping",
Destination: &settings.Build.AddHost,
Category: category,
},
&cli.StringSliceFlag{
Name: "platforms",
EnvVars: []string{"PLUGIN_PLATFORMS"},
Usage: "target platform for build",
Destination: &settings.Build.Platforms,
Category: category,
},
&cli.StringSliceFlag{
Name: "labels",
EnvVars: []string{"PLUGIN_LABELS"},
Usage: "labels to add to image",
Destination: &settings.Build.Labels,
Category: category,
},
&cli.StringFlag{
Name: "provenance",
EnvVars: []string{"PLUGIN_PROVENANCE"},
Usage: "generates provenance attestation for the build",
Destination: &settings.Build.Provenance,
Category: category,
},
&cli.StringFlag{
Name: "sbom",
EnvVars: []string{"PLUGIN_SBOM"},
Usage: "generates SBOM attestation for the build",
Destination: &settings.Build.SBOM,
Category: category,
},
&cli.GenericFlag{
Name: "secrets",
EnvVars: []string{"PLUGIN_SECRETS"},
Usage: "exposes secrets to the build",
Value: &plugin_types.StringSliceFlag{},
Category: category,
},
}
}

View File

@ -1,15 +1,12 @@
package main
package plugin
import (
"context"
"reflect"
"testing"
"github.com/thegeeklab/wp-docker-buildx/plugin"
wp "github.com/thegeeklab/wp-plugin-go/plugin"
)
func Test_pluginOptions(t *testing.T) {
func TestFlags(t *testing.T) {
tests := []struct {
name string
envs map[string]string
@ -32,14 +29,7 @@ func Test_pluginOptions(t *testing.T) {
t.Setenv(key, value)
}
settings := &plugin.Settings{}
options := wp.Options{
Name: "wp-docker-buildx",
Flags: settingsFlags(settings, wp.FlagsPluginCategory),
Execute: func(ctx context.Context) error { return nil },
}
got := plugin.New(options, settings)
got := New(func(_ context.Context) error { return nil })
_ = got.App.Run([]string{"wp-docker-buildx"})
_ = got.FlagsFromContext()

View File

@ -1,29 +1,12 @@
package plugin
import (
"io"
"net"
"os"
"os/exec"
"path/filepath"
)
func (p Plugin) startCoredns() {
cmd := exec.Command("coredns", "-conf", "/etc/coredns/Corefile")
if p.Settings.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = io.Discard
cmd.Stderr = io.Discard
}
go func() {
trace(cmd)
_ = cmd.Run()
}()
}
func getContainerIP() (string, error) {
func GetContainerIP() (string, error) {
netInterfaceAddrList, err := net.InterfaceAddrs()
if err != nil {
return "", err
@ -38,3 +21,18 @@ func getContainerIP() (string, error) {
return "", nil
}
func WriteDockerConf(path, conf string) error {
confPath := filepath.Join(path, ".docker", "config.json")
if err := os.MkdirAll(confPath, strictFilePerm); err != nil {
return err
}
err := os.WriteFile(path, []byte(conf), strictFilePerm)
if err != nil {
return err
}
return nil
}

1
testdata/Containerfile vendored Normal file
View File

@ -0,0 +1 @@
FROM alpine:latest