Compare commits

...

91 Commits

Author SHA1 Message Date
Robert Kaussow c9b8ea3c6a
chore: add deprecation notice 2023-01-15 21:58:39 +01:00
renovate[bot] 2c152cce3c chore(docker): update docker digests 2023-01-10 07:30:19 +00:00
Robert Kaussow 63baa5cc0d
ci: bump docker plugin to v20 (#76) 2023-01-08 15:44:10 +01:00
renovate[bot] e35e3f6208
chore(deps): update arm64v8/docker docker tag to v20 (#17) 2023-01-07 17:42:26 +01:00
renovate[bot] 9bef137ed6
chore(deps): update docker docker tag to v20 (#24) 2023-01-07 17:42:18 +01:00
Robert Kaussow fbc9427cda
chore: remove support for arm32 (#75) 2023-01-07 17:36:00 +01:00
Robert Kaussow 5303f6a5ca
docs: add example for custom registires (#74) 2022-12-21 10:49:07 +01:00
renovate[bot] dd6fc6ce42
fix(deps): update module github.com/thegeeklab/drone-plugin-lib/v2 to v2.2.1 (#73) 2022-12-21 08:45:23 +01:00
renovate[bot] dd65477400
fix(deps): update module github.com/urfave/cli/v2 to v2.23.7 (#72) 2022-12-20 21:06:38 +01:00
Robert Kaussow 5848ea5719
docs: fix properties file syntax due to changes in the theme (#71) 2022-11-24 15:09:19 +01:00
renovate[bot] 9b558675eb
fix(deps): update module github.com/urfave/cli/v2 to v2.23.5 (#69) 2022-11-24 09:45:56 +01:00
Robert Kaussow 81094ee3c5
ci: create symlink for xgo source directory (#70) 2022-11-24 09:43:43 +01:00
renovate[bot] 0e88134cab
fix(deps): update module github.com/thegeeklab/drone-plugin-lib/v2 to v2.2.0 (#68) 2022-10-31 19:59:29 +01:00
renovate[bot] d9a5ee9d4f
fix(deps): update module github.com/urfave/cli/v2 to v2.23.0 (#63) 2022-10-31 12:44:42 +01:00
renovate[bot] afe0ab1105 chore(deps): update dependency golangci/golangci-lint to v1.50.1 2022-10-24 04:56:18 +00:00
renovate[bot] c77d8d07b7 chore(deps): update dependency golangci/golangci-lint to v1.50.0 2022-10-10 04:57:50 +00:00
renovate[bot] 76e1cc61ec chore(deps): update dependency mvdan/gofumpt to v0.4.0 2022-10-03 04:28:36 +00:00
renovate[bot] 15da7b71db chore(deps): update dependency golangci/golangci-lint to v1.49.0 2022-08-29 05:46:08 +00:00
renovate[bot] afaaed742d chore(deps): update dependency golangci/golangci-lint to v1.48.0 2022-08-08 04:30:50 +00:00
renovate[bot] 3409c7c2ac
fix(deps): update module github.com/thegeeklab/drone-plugin-lib/v2 to v2.1.0 (#61) 2022-08-05 16:56:28 +02:00
renovate[bot] 17da5790a1
fix(deps): update module github.com/urfave/cli/v2 to v2.11.1 (#57) 2022-08-05 13:19:19 +02:00
Robert Kaussow 992117783a
chore: switch to go1.19 (#60) 2022-08-05 13:18:17 +02:00
renovate[bot] 7482633d35 chore(deps): update dependency golangci/golangci-lint to v1.47.2 2022-07-25 03:34:54 +00:00
renovate[bot] 59800776fc
fix(deps): update module github.com/sirupsen/logrus to v1.9.0 (#56) 2022-07-21 09:57:18 +02:00
Robert Kaussow d6219f41df
fix worind in readme and adjust repo config 2022-07-21 09:47:54 +02:00
Robert Kaussow 2932e7c616
ci: switch alpine-tools image 2022-07-17 20:45:22 +02:00
renovate[bot] f323347239
fix(deps): update module github.com/thegeeklab/drone-plugin-lib/v2 to v2.0.2 (#55) 2022-07-12 16:38:15 +02:00
Robert Kaussow 78691a84db
docs: fix spelling in readme 2022-07-12 09:12:30 +02:00
renovate[bot] ce9cd29b46
fix(deps): update module github.com/urfave/cli/v2 to v2.11.0 (#54) 2022-07-11 08:51:26 +02:00
renovate[bot] 64c662d7c0
fix(deps): update module github.com/thegeeklab/drone-plugin-lib/v2 to v2.0.1 (#53) 2022-06-20 21:04:08 +02:00
renovate[bot] 9450ca4416
fix(deps): update module github.com/urfave/cli/v2 to v2.10.1 (#52) 2022-06-20 10:26:14 +02:00
Robert Kaussow 1eb49849a9
docs: add privileged flag to usage example 2022-06-02 22:05:53 +02:00
Robert Kaussow f2b247463c
chore: remove unused flag remote.url 2022-06-02 21:51:35 +02:00
Robert Kaussow 29243448f0
fix: use proper logger info function instead if print 2022-06-02 14:26:47 +02:00
Robert Kaussow bd8a7ffab9
move privileged hint to usage section in docs 2022-05-30 21:59:44 +02:00
Robert Kaussow dd51fb117d
fix docs data file 2022-05-29 23:45:48 +02:00
Robert Kaussow 1b0ed2cbcf
docs: refactor plugin properties 2022-05-29 23:37:56 +02:00
Robert Kaussow 7bd5096b3e
refactor: add plugin flags to category (#51) 2022-05-29 23:17:32 +02:00
Robert Kaussow eedb9aee12
fix(deps): update module github.com/thegeeklab/drone-plugin-lib to v2 2022-05-29 22:52:18 +02:00
renovate[bot] ad71232103
fix(deps): update module github.com/urfave/cli/v2 to v2.8.1 (#50) 2022-05-29 14:06:31 +02:00
Renovate Bot 2eb88a0d33 chore(deps): update dependency golangci/golangci-lint to v1.46.2 2022-05-23 04:00:18 +00:00
renovate[bot] 593688263e
fix(deps): update module github.com/urfave/cli/v2 to v2.7.1 (#47) 2022-05-20 17:03:38 +02:00
Robert Kaussow 6aa6d8ae0c
refactor: switch to forked thegeeklab/drone-plugin-lib (#48) 2022-05-03 22:47:55 +02:00
Robert Kaussow b100a992d7
docs: fix hugo hint shortcode 2022-05-02 21:47:13 +02:00
Robert Kaussow d3ed9218b9
switch back to drone-docker:19 in ci 2022-04-25 21:19:27 +02:00
Robert Kaussow 5da3470af6
fix: fix docker daemon startup 2022-04-25 21:09:59 +02:00
Robert Kaussow 965a93f4ad
switch back to drone-docker:19 in ci 2022-04-25 20:52:12 +02:00
Robert Kaussow 90d501f42b
temp use v19.4.2 of drone-docker 2022-04-25 20:46:44 +02:00
Robert Kaussow 0a0372b4d2
temp use v19.4.2 of drone-docker 2022-04-25 20:44:00 +02:00
Robert Kaussow 2cd303ecfc
temp use v19.4.3 of drone-docker 2022-04-25 20:41:50 +02:00
Robert Kaussow 24fa9926ab
temp use latest of drone-docker 2022-04-25 20:39:11 +02:00
Robert Kaussow c74867e3c9
fix: fix docker daemon startup 2022-04-25 20:35:43 +02:00
renovate[bot] 5ee7554d2b
fix(deps): update module github.com/urfave/cli/v2 to v2.4.8 (#44) 2022-04-25 12:53:56 +02:00
Robert Kaussow 4b1e479d93
cleanup makefile (#45) 2022-04-25 12:48:52 +02:00
renovate[bot] ecfb0daa85
fix(deps): update module github.com/urfave/cli/v2 to v2.4.7 (#38) 2022-04-24 21:50:15 +02:00
Renovate Bot a539b08c6e chore(deps): update golang dev tools (non-major) 2022-04-24 14:39:56 +00:00
Robert Kaussow c9165a9eea
ci: refactor build tools and ci setup (#40) 2022-04-24 14:37:52 +02:00
Robert Kaussow 5174f15dcc
chore: switch to go1.18 as build requirement (#37) 2022-03-30 22:41:31 +02:00
renovate[bot] 4be401ee8a
fix(deps): update module github.com/urfave/cli/v2 to v2.4.0 (#35) 2022-03-27 12:50:11 +02:00
Robert Kaussow 4be5b750ce
docs: fix build command (#34) 2022-01-12 10:38:20 +01:00
Robert Kaussow dd20be95f0
docs: clarify versioning and handling of breaking changes 2022-01-12 10:08:16 +01:00
Robert Kaussow 49bd65b7f6
fix: fix auto_tag behavior to avoid unexpected publishing (#33) 2022-01-12 09:09:57 +01:00
Robert Kaussow 9024ebd41c
chore: end of the year maintenance 2021-12-21 10:54:54 +01:00
Robert Kaussow 8f17d4d078
fix renovate preset config 2021-12-21 09:56:02 +01:00
Robert Kaussow 4972fe7b83
chore: adjust changelog template to link to prs instead of issues (#32) 2021-12-12 14:04:14 +01:00
Robert Kaussow 64a2bd5a12
fix license name in readme (#31) 2021-11-16 13:41:53 +01:00
renovate[bot] 2e60fc70ae
fix(deps): update module honnef.co/go/tools to v0.2.2 (#30) 2021-11-14 15:21:58 +01:00
renovate[bot] d7582435bb
fix(deps): update module github.com/joho/godotenv to v1.4.0 (#29)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-25 12:09:13 +02:00
Robert Kaussow f3f4f0e544
improve changelog template 2021-09-22 11:48:48 +02:00
Robert Kaussow 41ff15a25b
improve drone-matrix template 2021-09-22 09:57:43 +02:00
Robert Kaussow 9ccadb6373
fix drone signature 2021-09-19 15:45:37 +02:00
Robert Kaussow 9fca0ead10
fix matrix notification template 2021-09-19 15:43:03 +02:00
Robert Kaussow 01123404e6
fix drone yaml format and switch to drone-matrix plugin (#28) 2021-09-19 14:32:48 +02:00
Robert Kaussow a46c75a9ac
docs: add missing plugin description 2021-09-11 21:30:19 +02:00
Robert Kaussow 9e32650a09
remove goreportcard from docs 2021-09-11 13:32:55 +02:00
Robert Kaussow 2b6b68ec3d
add meta information to docs 2021-09-11 13:27:00 +02:00
Robert Kaussow aeff25c33b
adjust parameter defaults 2021-09-11 13:20:16 +02:00
Robert Kaussow 7880e74254
fix docs link 2021-09-11 13:11:35 +02:00
Robert Kaussow cc96d1dc27
add branch protection for docs branch 2021-09-11 12:43:38 +02:00
Robert Kaussow 2ab3b97193
docs: prepare standalone plugin documentation (#27)
* docs: prepare standalone plugin documentation

* add markdownlint config
2021-09-11 12:40:31 +02:00
Robert Kaussow 3fd42b869c
docs: add parameter documentation (#26) 2021-09-11 12:02:03 +02:00
renovate[bot] 916bfebb37
fix(deps): update module honnef.co/go/tools to v0.2.1 (#25)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-08-23 20:57:53 +02:00
Renovate Bot 2268618947 chore(deps): update docker digests 2021-07-21 20:35:33 +00:00
Renovate Bot e07344197f chore(deps): update arm64v8/docker:19.03-dind docker digest 2021-07-14 21:52:23 +00:00
Renovate Bot 71bc16a7f3 chore(deps): update arm64v8/docker:19.03-dind docker digest 2021-06-04 01:37:10 +00:00
renovate[bot] 85b3a83807
fix(deps): update module honnef.co/go/tools to v0.2.0 (#20)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-05-25 18:03:23 +02:00
Robert Kaussow f3bea5c265
disable require branches to be up to date 2021-05-25 17:44:01 +02:00
Robert Kaussow 09f9cfa398
chore: update build env to golang 1.16 (#19)
* chore: update build env to golang 1.16

* update and cleanup dependencies

* add test deps

* add test deps
2021-05-10 09:03:35 +02:00
Robert Kaussow 7142c112ae
chore: improve generated changelog (#18) 2021-05-09 23:46:14 +02:00
Renovate Bot 9ac4950d85 chore(deps): update docker digests 2021-05-07 15:09:21 +00:00
Renovate Bot 183d631e38 chore(deps): update docker digests 2021-04-15 19:58:23 +00:00
31 changed files with 1014 additions and 702 deletions

View File

@ -7,9 +7,9 @@
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ (regexReplaceAll "(.*)/issues/(.*)" (regexReplaceAll "(Co-\\w*-by.*)" .Subject "") "${1}/pull/${2}") | trim }}
{{ end }}
{{ end -}}
{{- end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}

13
.dictionary Normal file
View File

@ -0,0 +1,13 @@
url
ip
mtu
dns
ipv6
dockerfile
og
gzip
json
config
host:ip
multiarch
DockerHub

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
*
!dist/

View File

@ -1,6 +1,5 @@
local PipelineTest = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'test',
platform: {
os: 'linux',
@ -8,53 +7,40 @@ local PipelineTest = {
},
steps: [
{
name: 'staticcheck',
image: 'golang:1.15',
name: 'deps',
image: 'golang:1.19',
commands: [
'go run honnef.co/go/tools/cmd/staticcheck ./...',
'make deps',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
},
{
name: 'lint',
image: 'golang:1.15',
image: 'golang:1.19',
commands: [
'go run golang.org/x/lint/golint -set_exit_status ./...',
'make lint',
],
volumes: [
{
name: 'gopath',
path: '/go',
},
],
},
{
name: 'vet',
image: 'golang:1.15',
commands: [
'go vet ./...',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
},
{
name: 'test',
image: 'golang:1.15',
image: 'golang:1.19',
commands: [
'go test -cover ./...',
'make test',
],
volumes: [
{
name: 'gopath',
name: 'godeps',
path: '/go',
},
],
@ -62,7 +48,7 @@ local PipelineTest = {
],
volumes: [
{
name: 'gopath',
name: 'godeps',
temp: {},
},
],
@ -74,7 +60,6 @@ local PipelineTest = {
local PipelineBuildBinaries = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-binaries',
platform: {
os: 'linux',
@ -83,47 +68,35 @@ local PipelineBuildBinaries = {
steps: [
{
name: 'build',
image: 'techknowlogick/xgo:go-1.15.x',
image: 'techknowlogick/xgo:go-1.19.x',
commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
'mkdir -p release/',
"cd cmd/drone-docker && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-docker .",
'mv /build/* /drone/src/release/',
'ls -l /drone/src/release/',
'ln -s /drone/src /source',
'make release',
],
},
{
name: 'executable',
image: 'alpine',
commands: [
'$(find release/ -executable -type f | grep drone-docker-linux-amd64) --help',
'$(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help',
],
},
{
name: 'compress',
image: 'alpine',
commands: [
'apk add upx',
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
'ls -lh release/',
],
},
{
name: 'checksum',
image: 'alpine',
commands: [
'cd release/ && sha256sum * > sha256sum.txt',
],
},
{
name: 'changelog',
name: 'changelog-generate',
image: 'thegeeklab/git-chglog',
commands: [
'git fetch -tq',
'git-chglog --no-color --no-emoji ${DRONE_TAG:---next-tag unreleased unreleased}',
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
],
},
{
name: 'changelog-format',
image: 'thegeeklab/alpine-tools',
commands: [
'prettier CHANGELOG.md',
'prettier -w CHANGELOG.md',
],
},
{
name: 'publish',
image: 'plugins/github-release',
@ -132,7 +105,7 @@ local PipelineBuildBinaries = {
api_key: {
from_secret: 'github_token',
},
files: ['release/*'],
files: ['dist/*'],
title: '${DRONE_TAG}',
note: 'CHANGELOG.md',
},
@ -153,7 +126,6 @@ local PipelineBuildBinaries = {
local PipelineBuildContainer(arch='amd64') = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'build-container-' + arch,
platform: {
os: 'linux',
@ -162,22 +134,18 @@ local PipelineBuildContainer(arch='amd64') = {
steps: [
{
name: 'build',
image: 'golang:1.15',
image: 'golang:1.19',
commands: [
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/drone-docker ./cmd/drone-docker',
'make build',
],
},
{
name: 'dryrun',
image: 'plugins/docker:19',
image: 'thegeeklab/drone-docker:20',
settings: {
config: { from_secret: 'docker_config' },
dry_run: true,
dockerfile: 'docker/Dockerfile.' + arch,
repo: 'thegeeklab/${DRONE_REPO_NAME}',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
depends_on: ['build'],
when: {
@ -186,9 +154,8 @@ local PipelineBuildContainer(arch='amd64') = {
},
{
name: 'publish-dockerhub',
image: 'plugins/docker:19',
image: 'thegeeklab/drone-docker:20',
settings: {
config: { from_secret: 'docker_config' },
auto_tag: true,
auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch,
@ -203,9 +170,8 @@ local PipelineBuildContainer(arch='amd64') = {
},
{
name: 'publish-quay',
image: 'plugins/docker:19',
image: 'thegeeklab/drone-docker:20',
settings: {
config: { from_secret: 'docker_config' },
auto_tag: true,
auto_tag_suffix: arch,
dockerfile: 'docker/Dockerfile.' + arch,
@ -228,9 +194,61 @@ local PipelineBuildContainer(arch='amd64') = {
},
};
local PipelineDocs = {
kind: 'pipeline',
name: 'docs',
platform: {
os: 'linux',
arch: 'amd64',
},
concurrency: {
limit: 1,
},
steps: [
{
name: 'markdownlint',
image: 'thegeeklab/markdownlint-cli',
commands: [
"markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
],
},
{
name: 'spellcheck',
image: 'thegeeklab/alpine-tools',
commands: [
"spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
],
environment: {
FORCE_COLOR: true,
NPM_CONFIG_LOGLEVEL: 'error',
},
},
{
name: 'publish',
image: 'plugins/gh-pages',
settings: {
username: { from_secret: 'github_username' },
password: { from_secret: 'github_token' },
pages_directory: '_docs/',
target_branch: 'docs',
},
when: {
ref: ['refs/heads/main'],
},
},
],
depends_on: [
'build-binaries',
'build-container-amd64',
'build-container-arm64',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineNotifications = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
name: 'notifications',
platform: {
os: 'linux',
@ -299,11 +317,11 @@ local PipelineNotifications = {
},
{
name: 'matrix',
image: 'plugins/matrix',
image: 'thegeeklab/drone-matrix',
settings: {
homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' },
},
@ -313,10 +331,7 @@ local PipelineNotifications = {
},
],
depends_on: [
'build-binaries',
'build-container-amd64',
'build-container-arm64',
'build-container-arm',
'docs',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
@ -329,6 +344,6 @@ local PipelineNotifications = {
PipelineBuildBinaries,
PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch='arm64'),
PipelineBuildContainer(arch='arm'),
PipelineDocs,
PipelineNotifications,
]

View File

@ -7,50 +7,39 @@ platform:
arch: amd64
steps:
- name: staticcheck
image: golang:1.15
commands:
- go run honnef.co/go/tools/cmd/staticcheck ./...
volumes:
- name: gopath
path: /go
- name: deps
image: golang:1.19
commands:
- make deps
volumes:
- name: godeps
path: /go
- name: lint
image: golang:1.15
commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
volumes:
- name: gopath
path: /go
- name: lint
image: golang:1.19
commands:
- make lint
volumes:
- name: godeps
path: /go
- name: vet
image: golang:1.15
commands:
- go vet ./...
volumes:
- name: gopath
path: /go
- name: test
image: golang:1.15
commands:
- go test -cover ./...
volumes:
- name: gopath
path: /go
- name: test
image: golang:1.19
commands:
- make test
volumes:
- name: godeps
path: /go
volumes:
- name: gopath
temp: {}
image_pull_secrets:
- docker_config
- name: godeps
temp: {}
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
kind: pipeline
@ -61,64 +50,51 @@ platform:
arch: amd64
steps:
- name: build
image: techknowlogick/xgo:go-1.15.x
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- mkdir -p release/
- cd cmd/drone-docker && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-docker .
- mv /build/* /drone/src/release/
- ls -l /drone/src/release/
- name: build
image: techknowlogick/xgo:go-1.19.x
commands:
- ln -s /drone/src /source
- make release
- name: executable
image: alpine
commands:
- $(find release/ -executable -type f | grep drone-docker-linux-amd64) --help
- name: executable
image: alpine
commands:
- $(find dist/ -executable -type f -iname ${DRONE_REPO_NAME}-linux-amd64) --help
- name: compress
image: alpine
commands:
- apk add upx
- find release/ -maxdepth 1 -executable -type f -exec upx {} \;
- ls -lh release/
- name: changelog-generate
image: thegeeklab/git-chglog
commands:
- git fetch -tq
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
- name: checksum
image: alpine
commands:
- cd release/ && sha256sum * > sha256sum.txt
- name: changelog-format
image: thegeeklab/alpine-tools
commands:
- prettier CHANGELOG.md
- prettier -w CHANGELOG.md
- name: changelog
image: thegeeklab/git-chglog
commands:
- git fetch -tq
- git-chglog --no-color --no-emoji ${DRONE_TAG:---next-tag unreleased unreleased}
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
- name: publish
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files:
- release/*
note: CHANGELOG.md
overwrite: true
title: ${DRONE_TAG}
when:
ref:
- refs/tags/**
image_pull_secrets:
- docker_config
- name: publish
image: plugins/github-release
settings:
api_key:
from_secret: github_token
files:
- dist/*
note: CHANGELOG.md
overwrite: true
title: ${DRONE_TAG}
when:
ref:
- refs/tags/**
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- test
- test
---
kind: pipeline
@ -129,82 +105,68 @@ platform:
arch: amd64
steps:
- name: build
image: golang:1.15
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-docker ./cmd/drone-docker
- name: build
image: golang:1.19
commands:
- make build
- name: dryrun
image: plugins/docker:19
settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64
dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/pull/**
depends_on:
- build
- name: dryrun
image: thegeeklab/drone-docker:20
settings:
dockerfile: docker/Dockerfile.amd64
dry_run: true
repo: thegeeklab/${DRONE_REPO_NAME}
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-dockerhub
image: thegeeklab/drone-docker:20
settings:
auto_tag: true
auto_tag_suffix: amd64
dockerfile: docker/Dockerfile.amd64
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-quay
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: amd64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.amd64
password:
from_secret: quay_password
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
- name: publish-quay
image: thegeeklab/drone-docker:20
settings:
auto_tag: true
auto_tag_suffix: amd64
dockerfile: docker/Dockerfile.amd64
password:
from_secret: quay_password
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- test
- test
---
kind: pipeline
@ -215,168 +177,117 @@ platform:
arch: arm64
steps:
- name: build
image: golang:1.15
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-docker ./cmd/drone-docker
- name: build
image: golang:1.19
commands:
- make build
- name: dryrun
image: plugins/docker:19
settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64
dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/pull/**
depends_on:
- build
- name: dryrun
image: thegeeklab/drone-docker:20
settings:
dockerfile: docker/Dockerfile.arm64
dry_run: true
repo: thegeeklab/${DRONE_REPO_NAME}
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-dockerhub
image: thegeeklab/drone-docker:20
settings:
auto_tag: true
auto_tag_suffix: arm64
dockerfile: docker/Dockerfile.arm64
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-quay
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: arm64
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm64
password:
from_secret: quay_password
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
- name: publish-quay
image: thegeeklab/drone-docker:20
settings:
auto_tag: true
auto_tag_suffix: arm64
dockerfile: docker/Dockerfile.arm64
password:
from_secret: quay_password
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- test
- test
---
kind: pipeline
name: build-container-arm
name: docs
platform:
os: linux
arch: arm
arch: amd64
concurrency:
limit: 1
steps:
- name: build
image: golang:1.15
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-docker ./cmd/drone-docker
- name: markdownlint
image: thegeeklab/markdownlint-cli
commands:
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
- name: dryrun
image: plugins/docker:19
settings:
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm
dry_run: true
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/pull/**
depends_on:
- build
- name: spellcheck
image: thegeeklab/alpine-tools
commands:
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
environment:
FORCE_COLOR: true
NPM_CONFIG_LOGLEVEL: error
- name: publish-dockerhub
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: arm
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm
password:
from_secret: docker_password
repo: thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: docker_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
- name: publish-quay
image: plugins/docker:19
settings:
auto_tag: true
auto_tag_suffix: arm
config:
from_secret: docker_config
dockerfile: docker/Dockerfile.arm
password:
from_secret: quay_password
registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username:
from_secret: quay_username
when:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
- name: publish
image: plugins/gh-pages
settings:
pages_directory: _docs/
password:
from_secret: github_token
target_branch: docs
username:
from_secret: github_username
when:
ref:
- refs/heads/main
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- test
- build-binaries
- build-container-amd64
- build-container-arm64
---
kind: pipeline
@ -387,95 +298,89 @@ platform:
arch: amd64
steps:
- name: manifest-dockerhub
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
spec: docker/manifest.tmpl
username:
from_secret: docker_username
when:
status:
- success
- name: manifest-dockerhub
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
spec: docker/manifest.tmpl
username:
from_secret: docker_username
when:
status:
- success
- name: manifest-quay
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: quay_password
spec: docker/manifest-quay.tmpl
username:
from_secret: quay_username
when:
status:
- success
- name: manifest-quay
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: quay_password
spec: docker/manifest-quay.tmpl
username:
from_secret: quay_username
when:
status:
- success
- name: pushrm-dockerhub
image: chko/docker-pushrm:1
environment:
DOCKER_PASS:
from_secret: docker_password
DOCKER_USER:
from_secret: docker_username
PUSHRM_FILE: README.md
PUSHRM_SHORT: Drone plugin to build multiarch Docker images
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
when:
status:
- success
- name: pushrm-dockerhub
image: chko/docker-pushrm:1
environment:
DOCKER_PASS:
from_secret: docker_password
DOCKER_USER:
from_secret: docker_username
PUSHRM_FILE: README.md
PUSHRM_SHORT: Drone plugin to build multiarch Docker images
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
when:
status:
- success
- name: pushrm-quay
image: chko/docker-pushrm:1
environment:
APIKEY__QUAY_IO:
from_secret: quay_token
PUSHRM_FILE: README.md
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
when:
status:
- success
- name: pushrm-quay
image: chko/docker-pushrm:1
environment:
APIKEY__QUAY_IO:
from_secret: quay_token
PUSHRM_FILE: README.md
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
when:
status:
- success
- name: matrix
image: plugins/matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
username:
from_secret: matrix_username
when:
status:
- success
- failure
image_pull_secrets:
- docker_config
- name: matrix
image: thegeeklab/drone-matrix
settings:
homeserver:
from_secret: matrix_homeserver
password:
from_secret: matrix_password
roomid:
from_secret: matrix_roomid
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
username:
from_secret: matrix_username
when:
status:
- success
- failure
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/heads/main
- refs/tags/**
status:
- success
- failure
- success
- failure
depends_on:
- build-binaries
- build-container-amd64
- build-container-arm64
- build-container-arm
- docs
---
kind: signature
hmac: 1c7dc109e0955ae8d3e01358642eff449ceb23ce888d35dfed3206060af11db9
hmac: 2678272f471334df973c0b9c0e8886dcf0941f5581b460b116fb48c88e7a14ba
...

17
.github/settings.yml vendored
View File

@ -1,6 +1,7 @@
repository:
name: drone-docker
description: Drone plugin to build multiarch Docker images
homepage: https://drone-plugin-index.geekdocs.de/plugins/drone-docker
topics: drone, drone-plugin
private: false
@ -48,8 +49,20 @@ branches:
protection:
required_pull_request_reviews: null
required_status_checks:
strict: true
strict: false
contexts:
- continuous-integration/drone/pr
enforce_admins: null
enforce_admins: true
required_linear_history: true
restrictions: null
- name: docs
protection:
required_pull_request_reviews: null
required_status_checks: null
enforce_admins: true
required_linear_history: true
restrictions:
apps: []
users: []
teams:
- bot

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/dist/
/release/
/drone-docker*

31
.golangci.yml Normal file
View File

@ -0,0 +1,31 @@
linters:
enable:
- gosimple
- deadcode
- typecheck
- govet
- errcheck
- staticcheck
- unused
- structcheck
- varcheck
- dupl
- gofmt
- misspell
- gocritic
- bidichk
- ineffassign
- revive
- gofumpt
- depguard
enable-all: false
disable-all: true
fast: false
run:
timeout: 3m
linters-settings:
gofumpt:
extra-rules: true
lang-version: "1.18"

6
.markdownlint.yml Normal file
View File

@ -0,0 +1,6 @@
---
default: True
MD013: False
MD041: False
MD004:
style: dash

3
.prettierignore Normal file
View File

@ -0,0 +1,3 @@
.drone.yml
*.tpl.md
LICENSE

View File

@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2021 Robert Kaussow <mail@thegeeklab.de>
Copyright 2022 Robert Kaussow <mail@thegeeklab.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

96
Makefile Normal file
View File

@ -0,0 +1,96 @@
# renovate: datasource=github-releases depName=mvdan/gofumpt
GOFUMPT_PACKAGE_VERSION := v0.4.0
# renovate: datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_PACKAGE_VERSION := v1.50.1
EXECUTABLE := drone-docker
DIST := dist
DIST_DIRS := $(DIST)
IMPORT := github.com/thegeeklab/$(EXECUTABLE)
GO ?= go
CWD ?= $(shell pwd)
PACKAGES ?= $(shell go list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@$(GOFUMPT_PACKAGE_VERSION)
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_PACKAGE_VERSION)
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
GENERATE ?=
XGO_VERSION := go-1.19.x
XGO_TARGETS ?= linux/amd64,linux/arm64
TAGS ?= netgo
ifndef VERSION
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
else
VERSION ?= $(shell git rev-parse --short HEAD)
endif
endif
ifndef DATE
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z")
endif
LDFLAGS += -s -w -X "main.BuildVersion=$(VERSION)" -X "main.BuildDate=$(DATE)"
.PHONY: all
all: clean build
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(DIST_DIRS)
.PHONY: fmt
fmt:
$(GO) run $(GOFUMPT_PACKAGE) -extra -w $(SOURCES)
.PHONY: golangci-lint
golangci-lint:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run
.PHONY: lint
lint: golangci-lint
.PHONY: generate
generate:
$(GO) generate $(GENERATE)
.PHONY: test
test:
$(GO) test -v -coverprofile coverage.out $(PACKAGES)
.PHONY: build
build: $(DIST)/$(EXECUTABLE)
$(DIST)/$(EXECUTABLE): $(SOURCES)
$(GO) build -v -tags '$(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -o $@ ./cmd/$(EXECUTABLE)
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: xgo
xgo: | $(DIST_DIRS)
$(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -v -ldflags '-extldflags "-static" $(LDFLAGS)' -tags '$(TAGS)' -targets '$(XGO_TARGETS)' -out $(EXECUTABLE) --pkg cmd/$(EXECUTABLE) .
cp /build/* $(CWD)/$(DIST)
ls -l $(CWD)/$(DIST)
.PHONY: checksum
checksum:
cd $(DIST); $(foreach file,$(wildcard $(DIST)/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
ls -l $(CWD)/$(DIST)
.PHONY: release
release: xgo checksum
.PHONY: deps
deps:
$(GO) mod download
$(GO) install $(GOFUMPT_PACKAGE)
$(GO) install $(GOLANGCI_LINT_PACKAGE)
$(GO) install $(XGO_PACKAGE)

View File

@ -1,5 +1,7 @@
# drone-docker
> DISCONTINUED: This image is no longer maintained and will be removed in the future.
Drone plugin to build multiarch Docker images
[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-docker?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-docker)
@ -8,53 +10,18 @@ Drone plugin to build multiarch Docker images
[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/drone-docker)](https://goreportcard.com/report/github.com/thegeeklab/drone-docker)
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-docker)](https://github.com/thegeeklab/drone-docker/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-docker)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-docker)](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE)
[![License: Apache-2.0](https://img.shields.io/github/license/thegeeklab/drone-docker)](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE)
Drone plugin to build multiarch Docker images. This plugin is a fork of [drone-plugins/drone-docker](https://github.com/drone-plugins/drone-docker).
Drone plugin to build multiarch Docker images. This plugin is a fork of [drone-plugins/drone-docker](https://github.com/drone-plugins/drone-docker). You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-docker).
## Docker Tags
## Versioning
Tags are following the main Docker version e.g. `19.03`, the second part is reflecting the plugin "version". A full example would be `19.03.5`.
## Build
Build the binary with the following command:
```Shell
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go build -v -a -tags netgo -o release/drone-docker
```
Build the Docker image with the following command:
```Shell
docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-docker .
```
## Usage
> Notice: Be aware that the tis plugin requires privileged capabilities, otherwise the integrated Docker daemon is not able to start.
```console
docker run --rm \
-e PLUGIN_TAG=latest \
-e PLUGIN_REPO=octocat/hello-world \
-e DRONE_COMMIT_SHA=00000000 \
-v $(pwd):$(pwd) \
-w $(pwd) \
--privileged \
thegeeklab/drone-docker --dry-run
```
The tags follow the major version of Docker, e.g. `19`, and the minor and patch parts reflect the `version` of the plugin. A full example would be `19.6.5`. Minor versions can introduce breaking changes, while patch versions can be considered non-breaking.
## Contributors
Special thanks goes to all [contributors](https://github.com/thegeeklab/drone-docker/graphs/contributors). If you would like to contribute,
please see the [instructions](https://github.com/thegeeklab/drone-docker/blob/main/CONTRIBUTING.md).
Special thanks to all [contributors](https://github.com/thegeeklab/drone-docker/graphs/contributors). If you would like to contribute, please see the [instructions](https://github.com/thegeeklab/drone-docker/blob/main/CONTRIBUTING.md).
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE) file for details.
This project is licensed under the Apache-2.0 License - see the [LICENSE](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE) file for details.

105
_docs/content/_index.md Normal file
View File

@ -0,0 +1,105 @@
---
title: drone-docker
---
[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-docker?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-docker)
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-docker)
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-docker)
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-docker)](https://github.com/thegeeklab/drone-docker/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-docker)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-docker)](https://github.com/thegeeklab/drone-docker/blob/main/LICENSE)
Drone plugin to build and publish multiarch Docker images.
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< toc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Versioning
The tags follow the major version of Docker, e.g. `19`, and the minor and patch parts reflect the `version` of the plugin. A full example would be `19.6.5`. Minor versions can introduce breaking changes, while patch versions can be considered non-breaking.
## Usage
{{< hint type=important >}}
Be aware that the this plugin requires [privileged](https://docs.drone.io/pipeline/docker/syntax/steps/#privileged-mode) capabilities, otherwise the integrated Docker daemon is not able to start.
{{< /hint >}}
```YAML
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/drone-docker
privileged: true
settings:
username: octocat
password: secure
repo: octocat/example
tags: latest
```
### Parameters
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< propertylist name=drone-docker.data sort=name >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
### Examples
**Push to other registries than DockerHub:**
If the created image is to be pushed to registries other than the default DockerHub, it is necessary to set `registry` and `repo` as fully-qualified name.
```YAML
kind: pipeline
name: default
steps:
- name: docker
image: thegeeklab/drone-docker
privileged: true
settings:
registry: ghcr.io
username: octocat
password: secret-access-token
repo: ghcr.io/octocat/example
tags: latest
```
## Build
Build the binary with the following command:
```Shell
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
make build
```
Build the Docker image with the following command:
```Shell
docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-docker .
```
## Test
```Shell
docker run --rm \
-e PLUGIN_TAG=latest \
-e PLUGIN_REPO=octocat/hello-world \
-e DRONE_COMMIT_SHA=00000000 \
-v $(pwd):$(pwd) \
-w $(pwd) \
--privileged \
thegeeklab/drone-docker --dry-run
```

197
_docs/data/data.yaml Normal file
View File

@ -0,0 +1,197 @@
---
properties:
- name: dry_run
description: Disable docker push.
type: bool
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
type: string
required: false
- name: bip
description: Allows 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.
type: list
required: false
- name: custom_dns_search
description: Custom docker daemon DNS search domain.
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: daemon_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: dockerfile
description: Set dockerfile to use for the image build.
defaultValue: Dockerfile
type: string
required: false
- name: context
description: Set the path of the build context to use.
defaultValue: .
type: string
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: build_args
description: Ccustom 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
description: Images to consider as cache sources.
type: list
required: false
- name: pull_image
description: Enforce to pull the base image at build time.
defaultValue: true
type: bool
required: false
- name: compress
description: Enable compression of the build context using gzip.
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.
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: purge
description: Enable cleanup of the docker environment at the end of a build.
defaultValue: true
type: bool
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
required: false

View File

@ -6,231 +6,261 @@ import (
)
// settingsFlags has the cli.Flags for the plugin.Settings.
func settingsFlags(settings *plugin.Settings) []cli.Flag {
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "dry-run",
Usage: "dry run disables docker push",
EnvVars: []string{"PLUGIN_DRY_RUN"},
Usage: "disable docker push",
Destination: &settings.Dryrun,
},
&cli.StringFlag{
Name: "remote.url",
Usage: "git remote url",
EnvVars: []string{"DRONE_REMOTE_URL"},
Destination: &settings.Build.Remote,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mirror",
Usage: "docker daemon registry 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",
Usage: "docker 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",
EnvVars: []string{"PLUGIN_STORAGE_PATH"},
Destination: &settings.Daemon.StoragePath,
Category: category,
},
&cli.StringFlag{
Name: "daemon.bip",
Usage: "docker daemon bride ip address",
EnvVars: []string{"PLUGIN_BIP"},
Usage: "allow the docker daemon to bride ip address",
Destination: &settings.Daemon.Bip,
Category: category,
},
&cli.StringFlag{
Name: "daemon.mtu",
Usage: "docker daemon custom mtu setting",
EnvVars: []string{"PLUGIN_MTU"},
Usage: "docker daemon custom mtu setting",
Destination: &settings.Daemon.MTU,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns",
Usage: "docker daemon dns server",
EnvVars: []string{"PLUGIN_CUSTOM_DNS"},
Usage: "custom docker daemon dns server",
Destination: &settings.Daemon.DNS,
Category: category,
},
&cli.StringSliceFlag{
Name: "daemon.dns-search",
Usage: "docker daemon dns search domains",
EnvVars: []string{"PLUGIN_CUSTOM_DNS_SEARCH"},
Usage: "custom docker daemon dns search domain",
Destination: &settings.Daemon.DNSSearch,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.insecure",
Usage: "docker daemon allows insecure registries",
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",
Usage: "docker daemon IPv6 networking",
EnvVars: []string{"PLUGIN_IPV6"},
Usage: "enable docker daemon IPv6 support",
Value: false,
Destination: &settings.Daemon.IPv6,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.experimental",
Usage: "docker daemon Experimental mode",
EnvVars: []string{"PLUGIN_EXPERIMENTAL"},
Usage: "enable docker daemon experimental mode",
Value: false,
Destination: &settings.Daemon.Experimental,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.debug",
Usage: "docker daemon executes in debug mode",
EnvVars: []string{"PLUGIN_DEBUG", "DOCKER_LAUNCH_DEBUG"},
Usage: "enable verbose debug mode for the docker daemon",
Value: false,
Destination: &settings.Daemon.Debug,
Category: category,
},
&cli.BoolFlag{
Name: "daemon.off",
Usage: "don't start the docker daemon",
EnvVars: []string{"PLUGIN_DAEMON_OFF"},
Usage: "disable the startup of the docker daemon",
Value: false,
Destination: &settings.Daemon.Disabled,
Category: category,
},
&cli.StringFlag{
Name: "dockerfile",
Usage: "build dockerfile",
Value: "Dockerfile",
EnvVars: []string{"PLUGIN_DOCKERFILE"},
Usage: "dockerfile to use for the image build",
Value: "Dockerfile",
Destination: &settings.Build.Dockerfile,
Category: category,
},
&cli.StringFlag{
Name: "context",
Usage: "build context",
Value: ".",
EnvVars: []string{"PLUGIN_CONTEXT"},
Usage: "path of the build context",
Value: ".",
Destination: &settings.Build.Context,
Category: category,
},
&cli.StringSliceFlag{
Name: "tags",
Usage: "build tags",
Value: cli.NewStringSlice([]string{"latest"}...),
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",
Usage: "default build tags",
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",
Usage: "default build tags with 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: "args",
Usage: "build 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",
Usage: "build args",
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",
Usage: "quiet docker build",
EnvVars: []string{"PLUGIN_QUIET"},
Usage: "enable suppression of the build output",
Value: false,
Destination: &settings.Build.Quiet,
Category: category,
},
&cli.StringFlag{
Name: "target",
Usage: "build target",
EnvVars: []string{"PLUGIN_TARGET"},
Usage: "build target to use",
Destination: &settings.Build.Target,
Category: category,
},
&cli.StringSliceFlag{
Name: "cache-from",
Usage: "images to consider as cache sources",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "images to consider as cache sources",
Destination: &settings.Build.CacheFrom,
},
&cli.BoolFlag{
Name: "squash",
Usage: "squash the layers at build time",
EnvVars: []string{"PLUGIN_SQUASH"},
Destination: &settings.Build.Squash,
Category: category,
},
&cli.BoolFlag{
Name: "pull-image",
Usage: "force pull base image at build time",
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",
Usage: "compress the build context using gzip",
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",
Usage: "docker repository",
EnvVars: []string{"PLUGIN_REPO"},
Usage: "repository name for the image",
Destination: &settings.Build.Repo,
Category: category,
},
&cli.StringFlag{
Name: "docker.registry",
Usage: "docker registry",
Value: "https://index.docker.io/v1/",
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",
Usage: "docker username",
EnvVars: []string{"PLUGIN_USERNAME", "DOCKER_USERNAME"},
Usage: "username for registry authentication",
Destination: &settings.Login.Username,
Category: category,
},
&cli.StringFlag{
Name: "docker.password",
Usage: "docker password",
EnvVars: []string{"PLUGIN_PASSWORD", "DOCKER_PASSWORD"},
Usage: "password for registry authentication",
Destination: &settings.Login.Password,
Category: category,
},
&cli.StringFlag{
Name: "docker.email",
Usage: "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",
Usage: "docker json dockerconfig content",
EnvVars: []string{"PLUGIN_CONFIG", "DOCKER_PLUGIN_CONFIG"},
Usage: "content of the docker daemon json config",
Destination: &settings.Login.Config,
Category: category,
},
&cli.BoolFlag{
Name: "docker.purge",
Usage: "docker should cleanup images",
EnvVars: []string{"PLUGIN_PURGE"},
Usage: "enable cleanup of the docker environment at the end of a build",
Value: true,
Destination: &settings.Cleanup,
Category: category,
},
&cli.BoolFlag{
Name: "no-cache",
Usage: "do not use cached intermediate containers",
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",
Usage: "additional host:IP mapping",
EnvVars: []string{"PLUGIN_ADD_HOST"},
Usage: "additional host:ip mapping",
Destination: &settings.Build.AddHost,
Category: category,
},
}
}

View File

@ -1,35 +1,43 @@
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/sirupsen/logrus"
"github.com/thegeeklab/drone-docker/plugin"
"github.com/urfave/cli/v2"
"github.com/drone-plugins/drone-plugin-lib/errors"
"github.com/drone-plugins/drone-plugin-lib/urfave"
"github.com/thegeeklab/drone-plugin-lib/v2/urfave"
)
var version = "unknown"
var (
BuildVersion = "devel"
BuildDate = "00000000"
)
func main() {
settings := &plugin.Settings{}
if _, err := os.Stat("/run/drone/env"); err == nil {
godotenv.Overload("/run/drone/env")
_ = godotenv.Overload("/run/drone/env")
}
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("%s version=%s date=%s\n", c.App.Name, c.App.Version, BuildDate)
}
app := &cli.App{
Name: "drone-docker",
Usage: "build docker container with DinD",
Version: version,
Flags: append(settingsFlags(settings), urfave.Flags()...),
Version: BuildVersion,
Flags: append(settingsFlags(settings, urfave.FlagsPluginCategory), urfave.Flags()...),
Action: run(settings),
}
if err := app.Run(os.Args); err != nil {
errors.HandleExit(err)
logrus.Fatal(err)
}
}
@ -44,19 +52,11 @@ func run(settings *plugin.Settings) cli.ActionFunc {
)
if err := plugin.Validate(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("validation failed: %w", err)
return fmt.Errorf("validation failed: %w", err)
}
if err := plugin.Execute(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("execution failed: %w", err)
return fmt.Errorf("execution failed: %w", err)
}
return nil

View File

@ -1,4 +1,4 @@
FROM amd64/docker:19.03-dind@sha256:fcce60ebd97400dac9185d07168d2b994632e3531c0955784e9d161e36ee1231
FROM amd64/docker:20.10-dind@sha256:56a2d342dd7f25fd604f71513f765526bd522f3c256bead83b6d30c5a8006fa6
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
@ -18,6 +18,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
ADD release/amd64/drone-docker /bin/
ADD dist/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]

View File

@ -1,23 +0,0 @@
FROM arm32v7/docker:19.03-dind@sha256:f998921d365053bf7e3f98794f6c23ca44e6809832d78105bc4d2da6bb8521ed
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.title="drone-docker"
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/drone-docker"
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/drone-docker"
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/drone-docker"
ENV DOCKER_HOST=unix:///var/run/docker.sock
RUN apk --update add --virtual .build-deps curl && \
mkdir -p /etc/docker/ && \
curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \
sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \
chmod 600 /etc/docker/default.json && \
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
ADD release/arm/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]

View File

@ -1,4 +1,4 @@
FROM arm64v8/docker:19.03-dind@sha256:cfa6db10c8be33c394543b867a8570410bce4db7de2a3e51d21974f28d89e7a5
FROM arm64v8/docker:20.10-dind@sha256:26c7da097331ba685a7314fcfc0eb608b86b4074bab5e1beaeb57d744c5c060a
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
@ -18,6 +18,6 @@ RUN apk --update add --virtual .build-deps curl && \
rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
ADD release/arm64/drone-docker /bin/
ADD dist/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "drone-docker"]

View File

@ -16,9 +16,3 @@ manifests:
architecture: arm64
os: linux
variant: v8
- image: quay.io/thegeeklab/drone-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
platform:
architecture: arm
os: linux
variant: v7

View File

@ -16,9 +16,3 @@ manifests:
architecture: arm64
os: linux
variant: v8
- image: thegeeklab/drone-docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
platform:
architecture: arm
os: linux
variant: v7

23
go.mod
View File

@ -1,16 +1,19 @@
module github.com/thegeeklab/drone-docker
go 1.15
go 1.19
require (
github.com/coreos/go-semver v0.3.0
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/drone-plugins/drone-plugin-lib v0.4.0
github.com/joho/godotenv v1.3.0
github.com/kr/pretty v0.1.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli/v2 v2.3.0
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
github.com/joho/godotenv v1.4.0
github.com/sirupsen/logrus v1.9.0
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.1
github.com/urfave/cli/v2 v2.23.7
)
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

79
go.sum
View File

@ -1,66 +1,31 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/drone-plugins/drone-plugin-lib v0.4.0 h1:qywEYGhquUuid6zNLmKia8CWY1TUa8jPQQ/G9ozfAmc=
github.com/drone-plugins/drone-plugin-lib v0.4.0/go.mod h1:EgqogX38GoJFtckeSQyhBJYX8P+KWBPhdprAVvyRxF8=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g=
github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
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/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
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/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.8.0 h1:nfhvjKcUMhBMVqbKHJlk5RPrrfYr/NMo3692g0dwfWU=
github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061 h1:DQmQoKxQWtyybCtX/3dIuDBcAhFszqq8YiNeS6sNu1c=
golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY=
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.1 h1:fta32M+y6aHG/BX+Kwxo9DQAcYpTyCBHn7sAm2qjfL0=
github.com/thegeeklab/drone-plugin-lib/v2 v2.2.1/go.mod h1:Bu++VS6GXEWCHQdzR65dPsGtBGOMuqAQPiRVBaa+HrY=
github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY=
github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
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/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -1,13 +1,15 @@
package plugin
import (
"io/ioutil"
"io"
"os"
)
const dockerExe = "/usr/local/bin/docker"
const dockerdExe = "/usr/local/bin/dockerd"
const dockerHome = "/root/.docker/"
const (
dockerExe = "/usr/local/bin/docker"
dockerdExe = "/usr/local/bin/dockerd"
dockerHome = "/root/.docker/"
)
func (p Plugin) startDaemon() {
cmd := commandDaemon(p.settings.Daemon)
@ -15,11 +17,11 @@ func (p Plugin) startDaemon() {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
cmd.Stdout = io.Discard
cmd.Stderr = io.Discard
}
go func() {
trace(cmd)
cmd.Run()
_ = cmd.Run()
}()
}

View File

@ -66,9 +66,6 @@ func commandBuild(build Build) *exec.Cmd {
}
args = append(args, build.Context)
if build.Squash {
args = append(args, "--squash")
}
if build.Compress {
args = append(args, "--compress")
}

View File

@ -2,7 +2,6 @@ package plugin
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -40,7 +39,6 @@ type Login struct {
// Build defines Docker build parameters.
type Build struct {
Remote string // Git remote URL
Name string // Git commit sha used as docker default named tag
Ref string // Git commit ref
Branch string // Git repository branch
@ -52,7 +50,6 @@ type Build struct {
Args cli.StringSlice // Docker build args
ArgsEnv cli.StringSlice // Docker build args from env
Target string // Docker build target
Squash bool // Docker build squash
Pull bool // Docker build pull
CacheFrom cli.StringSlice // Docker build cache-from
Compress bool // Docker build compress
@ -93,12 +90,12 @@ func (p *Plugin) Validate() error {
p.settings.Build.TagsSuffix,
)
if err != nil {
logrus.Printf("cannot build docker image for %s, invalid semantic version", p.settings.Build.Ref)
logrus.Infof("cannot generate tags from %s, invalid semantic version", p.settings.Build.Ref)
return err
}
p.settings.Build.Tags = *cli.NewStringSlice(tag...)
} else {
logrus.Printf("skipping automated docker build for %s", p.settings.Build.Ref)
logrus.Infof("skip auto-tagging, not on default branch or tag")
return nil
}
}
@ -126,10 +123,12 @@ func (p *Plugin) Execute() error {
// Create Auth Config File
if p.settings.Login.Config != "" {
os.MkdirAll(dockerHome, 0600)
if err := os.MkdirAll(dockerHome, 0o600); err != nil {
return fmt.Errorf("failed to create docker home: %s", err)
}
path := filepath.Join(dockerHome, "config.json")
err := ioutil.WriteFile(path, []byte(p.settings.Login.Config), 0600)
err := os.WriteFile(path, []byte(p.settings.Login.Config), 0o600)
if err != nil {
return fmt.Errorf("error writing config.json: %s", err)
}
@ -153,11 +152,6 @@ func (p *Plugin) Execute() error {
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
}
if p.settings.Build.Squash && !p.settings.Daemon.Experimental {
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
p.settings.Build.Squash = false
}
// add proxy build args
addProxyBuildArgs(&p.settings.Build)
@ -192,13 +186,15 @@ func (p *Plugin) Execute() error {
trace(cmd)
err := cmd.Run()
if err != nil && isCommandPull(cmd.Args) {
switch {
case err != nil && isCommandPull(cmd.Args):
fmt.Printf("Could not pull cache-from image %s. Ignoring...\n", cmd.Args[2])
} else if err != nil && isCommandPrune(cmd.Args) {
case err != nil && isCommandPrune(cmd.Args):
fmt.Printf("Could not prune system containers. Ignoring...\n")
} else if err != nil && isCommandRmi(cmd.Args) {
case err != nil && isCommandRmi(cmd.Args):
fmt.Printf("Could not remove image %s. Ignoring...\n", cmd.Args[2])
} else if err != nil {
case err != nil:
return err
}
}

View File

@ -1,7 +1,7 @@
package plugin
import (
"github.com/drone-plugins/drone-plugin-lib/drone"
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
)
// Plugin implements drone.Plugin to provide the plugin implementation.

View File

@ -27,7 +27,7 @@ func DefaultTagSuffix(ref, suffix string) ([]string, error) {
return tags, nil
}
func splitOff(input string, delim string) string {
func splitOff(input, delim string) string {
parts := strings.SplitN(input, delim, 2)
if len(parts) == 2 {

View File

@ -6,7 +6,7 @@ import (
)
func Test_stripTagPrefix(t *testing.T) {
var tests = []struct {
tests := []struct {
Before string
After string
}{
@ -24,12 +24,12 @@ func Test_stripTagPrefix(t *testing.T) {
}
func TestDefaultTags(t *testing.T) {
var tests = []struct {
tests := []struct {
Before string
After []string
}{
{"", []string{"latest"}},
{"refs/heads/master", []string{"latest"}},
{"refs/heads/main", []string{"latest"}},
{"refs/tags/0.9.0", []string{"0.9", "0.9.0"}},
{"refs/tags/1.0.0", []string{"1", "1.0", "1.0.0"}},
{"refs/tags/v1.0.0", []string{"1", "1.0", "1.0.0"}},
@ -50,7 +50,7 @@ func TestDefaultTags(t *testing.T) {
}
func TestDefaultTagsError(t *testing.T) {
var tests = []string{
tests := []string{
"refs/tags/x1.0.0",
"refs/tags/20190203",
}
@ -64,7 +64,7 @@ func TestDefaultTagsError(t *testing.T) {
}
func TestDefaultTagSuffix(t *testing.T) {
var tests = []struct {
tests := []struct {
Before string
Suffix string
After []string
@ -142,9 +142,9 @@ func Test_stripHeadPrefix(t *testing.T) {
}{
{
args: args{
ref: "refs/heads/master",
ref: "refs/heads/main",
},
want: "master",
want: "main",
},
}
for _, tt := range tests {
@ -167,8 +167,8 @@ func TestUseDefaultTag(t *testing.T) {
{
name: "latest tag for default branch",
args: args{
ref: "refs/heads/master",
defaultBranch: "master",
ref: "refs/heads/main",
defaultBranch: "main",
},
want: true,
},
@ -176,7 +176,7 @@ func TestUseDefaultTag(t *testing.T) {
name: "build from tags",
args: args{
ref: "refs/tags/v1.0.0",
defaultBranch: "master",
defaultBranch: "main",
},
want: true,
},
@ -184,7 +184,7 @@ func TestUseDefaultTag(t *testing.T) {
name: "skip build for not default branch",
args: args{
ref: "refs/heads/develop",
defaultBranch: "master",
defaultBranch: "main",
},
want: false,
},

View File

@ -1,4 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>thegeeklab/renovate-presets"]
"extends": ["github>thegeeklab/renovate-presets:golang"]
}