69 Commits

Author SHA1 Message Date
Don
1b71fe6cdd Update Windows Dockerfiles 2020-10-14 07:24:18 -07:00
Brad Rydzewski
e4056d8499 Merge pull request #296 from robertstettner/added-godotenv-for-non-base
Added env-file with godotenv to all non-base implementations of plugin
2020-08-11 11:24:23 -04:00
Robert Stettner
a5076e74dc Added env-file with godotenv to all non-base implementations of plugin 2020-08-05 16:28:21 +01:00
Brad Rydzewski
d913d6e7dc Merge pull request #279 from drone-plugins/feature/semver-fail
semver parsing fails pipeline step
2020-06-08 14:57:13 -04:00
Brad Rydzewski
1482cb1143 Merge pull request #285 from luthermonson/prune-loc
changed prune to 3rd arg in check
2020-05-28 12:06:46 -07:00
Luther
eb6d634460 changed prune to 3rd arg in check 2020-05-28 11:48:36 -07:00
Brad Rydzewski
77396e3f59 Clarify use of Docker-in-Docker [CI SKIP] 2020-05-28 13:22:31 -04:00
Brad Rydzewski
675553c96d Merge pull request #262 from tuxity/docker_update
Update Docker to 19.03.8
2020-05-28 10:20:37 -07:00
Brad Rydzewski
d929356ba1 Merge pull request #281 from luthermonson/no-error-cleanup
Adding Ignore Checks for prune and rmi
2020-05-22 13:48:44 -07:00
Luther
9701f08184 adding ignore checks for prune and rmi 2020-05-22 13:15:19 -07:00
Brad Rydzewski
6cc2e43e64 semver parsing fails pipeline step 2020-05-19 13:26:13 -04:00
Thomas Boerger
b5598ee56d Merge pull request #274 from gary-kim/enh/noid/quiet-option
Add quiet build option
2020-05-18 09:41:22 +02:00
Thomas Boerger
8219e78eca Merge branch 'master' into enh/noid/quiet-option 2020-05-18 09:36:48 +02:00
Kévin Darcel
23b5e6bcd9 Update linux Dockerfile to 19.03.8 2020-05-05 15:31:17 -05:00
Kévin Darcel
56e470dcda Start daemon with Unix socket only
Mostly reproduce flow of https://github.com/docker-library/docker/blob/master/19.03/dind/dockerd-entrypoint.sh#L130
TCP socket with or without TLS isn't really needed for our usecase so
it's disable
2020-05-02 17:09:35 -05:00
Kévin Darcel
8d54531f2f Update to docker 19.03.05 2020-05-02 17:09:35 -05:00
Brad Rydzewski
05c329ab6e Merge pull request #266 from luthermonson/win-1909
adding windows 1909
2020-05-02 08:58:40 -07:00
Gary Kim
0099cd6056 Add quiet build option
This adds the option for using the `--quiet` flag during builds.

Signed-off-by: Gary Kim <gary@garykim.dev>
2020-04-29 14:11:31 +08:00
Thomas Boerger
00ee2c290c Merge pull request #259 from aviettran/master
Update AWS SDK
2020-04-16 09:29:39 +02:00
Thomas Boerger
65bb87f497 Merge branch 'master' into master 2020-04-16 09:24:34 +02:00
Brad Rydzewski
f2aeb0f7fc fix docker home path on windows 2020-03-24 14:34:54 -07:00
Brad Rydzewski
9488d3352e fix docker home const for windows 2020-03-24 14:15:07 -07:00
Brad Rydzewski
528dc0a7b3 update config.json messaging 2020-03-24 13:49:10 -07:00
Brad Rydzewski
cc112b3ed0 Merge pull request #269 from Koma-Andrea/master [ci skip]
Added docker configuration
2020-03-24 13:43:43 -07:00
Brad Rydzewski
122443b3e6 minor variable name change 2020-03-24 13:40:35 -07:00
Andrea Cervesato
063f479004 Using more generic configuration & respecting win 2020-03-24 21:00:24 +01:00
Andrea Cervesato
18c4e995d3 Added AuthConfig to login to multiple registry 2020-03-24 19:20:52 +01:00
Luther Monson
bae9d8ddbf adding windows 1909 2020-03-12 10:46:57 -07:00
Adam Tran
af9fdad1d9 update urfave/cli to 1.22.2 2020-01-02 16:32:11 -05:00
Adam Tran
196c393da4 update sum 2020-01-02 11:41:54 -05:00
Adam Tran
c69ad3dfaf remove urfave/cli 2020-01-02 11:40:30 -05:00
Adam Tran
c6dab33e03 Update AWS SDK 2020-01-02 09:42:44 -05:00
Thomas Boerger
1f0cfcc3ef Merge pull request #256 from recamshak/build-add-host
Add build add-host
2019-12-11 21:41:59 +01:00
recamshak
17639d6cbf Add build add-host 2019-12-11 09:33:26 +09:00
Brad Rydzewski
4c09b80365 Merge pull request #248 from mjschultz/master
ECR: Respect the registry option
2019-10-16 10:07:49 -10:00
Brad Rydzewski
39da697e1e Merge branch 'master' into master 2019-10-16 10:03:13 -10:00
Thomas Boerger
5be3f2c282 Merge pull request #233 from jwalton9/ecr-assume-role
Add Assume Role Option For ECR Pushes
2019-10-15 11:30:33 +02:00
Thomas Boerger
0d7f74aa65 Merge branch 'master' into ecr-assume-role 2019-10-14 20:22:50 +02:00
Joe Walton
2184682042 Apply suggestions from code review
Co-Authored-By: Lauris BH <lauris@nix.lv>
2019-10-14 10:20:32 +01:00
Thomas Boerger
2124bb2c8d Merge pull request #252 from drone-plugins/revert-245-revert-243-revert-242-appendtags
Revert "Reapply append tags with autotag instead of replacing"
2019-10-10 09:45:32 +02:00
Thomas Boerger
aa2a947782 Revert Reapply append tags with autotag instead of replacing 2019-10-10 09:34:38 +02:00
Thomas Boerger
6e2e66de0e Merge pull request #245 from drone-plugins/revert-243-revert-242-appendtags
Reapply append tags with autotag instead of replacing
2019-09-17 21:43:30 +02:00
Thomas Boerger
1672823733 Merge branch 'master' into revert-243-revert-242-appendtags 2019-09-17 21:39:32 +02:00
Brad Rydzewski
261afaa9ed use nanoserver for 1809 2019-08-15 10:54:51 -07:00
Michael J. Schultz
7b060dd935 Merge remote-tracking branch 'benwilson512/master' 2019-08-15 12:08:48 -05:00
Brad Rydzewski
3336758708 disable starting the daemon on windows 2019-08-14 12:51:43 -07:00
Brad Rydzewski
98722a6680 remove 1903 netapi32 2019-08-14 11:29:53 -07:00
Brad Rydzewski
8d8851bf98 use windowsservercore for 1903 2019-08-14 10:34:18 -07:00
Brad Rydzewski
65e411842e fix Dockerfile path 2019-08-13 15:52:36 -07:00
Brad Rydzewski
d880d528ec enable 1903 build 2019-08-13 13:35:12 -07:00
Brad Rydzewski
43c45fed4d fix dependency graph 2019-08-09 10:46:20 -07:00
Brad Rydzewski
acd38d572c remove windows jsonnet 2019-08-09 10:45:29 -07:00
Brad Rydzewski
ac4f39236e remove windows specific yaml 2019-08-09 10:45:16 -07:00
Brad Rydzewski
90fab79dc3 enable windows 1809 builds 2019-08-09 10:44:41 -07:00
Thomas Boerger
e8be4981da Revert "Revert "append tags with autotag instead of replacing"" 2019-08-07 09:48:46 +02:00
Brad Rydzewski
1bdd82a4a7 attempt to revert to 18.09.0 base image 2019-08-06 13:56:23 -07:00
Brad Rydzewski
3c2802ea17 microbadger not fail pipeline 2019-08-06 13:32:45 -07:00
Brad Rydzewski
f65d51bcc8 update yaml to use plugins/docker:18 (known working version) 2019-08-06 13:19:30 -07:00
Brad Rydzewski
e7fc4bb483 Merge pull request #243 from drone-plugins/revert-242-appendtags
Revert "append tags with autotag instead of replacing"
2019-08-06 13:09:36 -07:00
Brad Rydzewski
b47dd5d7bc Revert "append tags with autotag instead of replacing" 2019-08-06 13:09:07 -07:00
Thomas Boerger
14e80ddb03 Merge pull request #242 from foosinn/appendtags
append tags with autotag instead of replacing
2019-08-06 21:30:34 +02:00
Stefan Schwarz
db96c9a78b append tags with autotag instead of replacing
closes #201
2019-07-24 11:12:22 +02:00
Joe Walton
b5b34938c5 Add Assume Role Option For ECR Pushes 2019-04-24 13:31:46 +01:00
Robert Lippens
ebce953fc4 Create ACR plugin extension (#228)
* initial commit

* switch order of args for trimPrefix
2019-03-28 11:20:36 +01:00
Dominik Schmidt
13f2944b04 Update docker base image on Linux (#227) 2019-03-27 13:51:18 +01:00
Thomas Boerger
d49219b56b Fix auto_tag for manifests 2019-03-27 13:39:24 +01:00
Thomas Boerger
0e57ad9715 Merge branch 'master' into master 2019-01-19 21:40:28 +01:00
Ben Wilson
f69f3d2b74 Merge remote-tracking branch 'upstream/master' 2018-11-28 08:33:15 -05:00
Ben Wilson
babff9c7ad use the specified registry 2018-10-27 15:27:43 -04:00
45 changed files with 976 additions and 857 deletions

View File

@@ -21,6 +21,15 @@ local pipeline = import 'pipeline.libsonnet';
'linux-arm',
]),
pipeline.build('acr', 'linux', 'amd64'),
pipeline.build('acr', 'linux', 'arm64'),
pipeline.build('acr', 'linux', 'arm'),
pipeline.notifications('acr', depends_on=[
'linux-amd64',
'linux-arm64',
'linux-arm',
]),
pipeline.build('ecr', 'linux', 'amd64'),
pipeline.build('ecr', 'linux', 'arm64'),
pipeline.build('ecr', 'linux', 'arm'),

View File

@@ -1,26 +0,0 @@
local pipeline = import 'pipeline.libsonnet';
[
pipeline.test('windows', 'amd64', '1803'),
pipeline.build('docker', 'windows', 'amd64', '1803'),
pipeline.build('docker', 'windows', 'amd64', '1809'),
pipeline.notifications('docker', 'windows', 'amd64', '1809', [
'windows-1803',
'windows-1809'
]),
pipeline.build('gcr', 'windows', 'amd64', '1803'),
pipeline.build('gcr', 'windows', 'amd64', '1809'),
pipeline.notifications('gcr', 'windows', 'amd64', '1809', [
'windows-1803',
'windows-1809'
]),
pipeline.build('ecr', 'windows', 'amd64', '1803'),
pipeline.build('ecr', 'windows', 'amd64', '1809'),
pipeline.notifications('ecr', 'windows', 'amd64', '1809', [
'windows-1803',
'windows-1809'
]),
]

View File

@@ -1,706 +0,0 @@
---
kind: pipeline
name: testing
platform:
os: windows
arch: amd64
version: 1803
steps:
- name: vet
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- go vet ./...
environment:
GO111MODULE: on
volumes:
- name: gopath
path: C:\\gopath
- name: test
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- go test -cover ./...
environment:
GO111MODULE: on
volumes:
- name: gopath
path: C:\\gopath
volumes:
- name: gopath
temp: {}
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
---
kind: pipeline
name: windows-1803-docker
platform:
os: windows
arch: amd64
version: 1803
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: executable
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- ./release/windows/amd64/drone-docker.exe --help
- name: dryrun
pull: always
image: plugins/docker:windows-1803
settings:
daemon_off: true
dockerfile: docker/docker/Dockerfile.windows.1803
dry_run: true
password:
from_secret: docker_password
repo: plugins/docker
tags: windows-1803
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1803
settings:
auto_tag: true
auto_tag_suffix: windows-1803
daemon_off: true
dockerfile: docker/docker/Dockerfile.windows.1803
password:
from_secret: docker_password
repo: plugins/docker
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- testing
---
kind: pipeline
name: windows-1809-docker
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: executable
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- ./release/windows/amd64/drone-docker.exe --help
- name: dryrun
pull: always
image: plugins/docker:windows-1809
settings:
daemon_off: true
dockerfile: docker/docker/Dockerfile.windows.1809
dry_run: true
password:
from_secret: docker_password
repo: plugins/docker
tags: windows-1809
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1809
settings:
auto_tag: true
auto_tag_suffix: windows-1809
daemon_off: true
dockerfile: docker/docker/Dockerfile.windows.1809
password:
from_secret: docker_password
repo: plugins/docker
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- testing
---
kind: pipeline
name: notifications-docker
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: manifest
pull: always
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: docker/docker/manifest.tmpl
username:
from_secret: docker_username
- name: microbadger
pull: always
image: plugins/webhook
settings:
urls:
from_secret: microbadger_docker
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
depends_on:
- windows-1803-docker
- windows-1809-docker
---
kind: pipeline
name: windows-1803-gcr
platform:
os: windows
arch: amd64
version: 1803
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:windows-1803
settings:
daemon_off: true
dockerfile: docker/gcr/Dockerfile.windows.1803
dry_run: true
password:
from_secret: docker_password
repo: plugins/gcr
tags: windows-1803
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1803
settings:
auto_tag: true
auto_tag_suffix: windows-1803
daemon_off: true
dockerfile: docker/gcr/Dockerfile.windows.1803
password:
from_secret: docker_password
repo: plugins/gcr
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- windows-1803-docker
---
kind: pipeline
name: windows-1809-gcr
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gcr.exe ./cmd/drone-gcr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:windows-1809
settings:
daemon_off: true
dockerfile: docker/gcr/Dockerfile.windows.1809
dry_run: true
password:
from_secret: docker_password
repo: plugins/gcr
tags: windows-1809
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1809
settings:
auto_tag: true
auto_tag_suffix: windows-1809
daemon_off: true
dockerfile: docker/gcr/Dockerfile.windows.1809
password:
from_secret: docker_password
repo: plugins/gcr
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- windows-1809-docker
---
kind: pipeline
name: notifications-gcr
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: manifest
pull: always
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: docker/gcr/manifest.tmpl
username:
from_secret: docker_username
- name: microbadger
pull: always
image: plugins/webhook
settings:
urls:
from_secret: microbadger_gcr
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
depends_on:
- windows-1803-gcr
- windows-1809-gcr
---
kind: pipeline
name: windows-1803-ecr
platform:
os: windows
arch: amd64
version: 1803
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:windows-1803
settings:
daemon_off: true
dockerfile: docker/ecr/Dockerfile.windows.1803
dry_run: true
password:
from_secret: docker_password
repo: plugins/ecr
tags: windows-1803
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1803
settings:
auto_tag: true
auto_tag_suffix: windows-1803
daemon_off: true
dockerfile: docker/ecr/Dockerfile.windows.1803
password:
from_secret: docker_password
repo: plugins/ecr
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- windows-1803-docker
---
kind: pipeline
name: windows-1809-ecr
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-ecr.exe ./cmd/drone-ecr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:windows-1809
settings:
daemon_off: true
dockerfile: docker/ecr/Dockerfile.windows.1809
dry_run: true
password:
from_secret: docker_password
repo: plugins/ecr
tags: windows-1809
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:windows-1809
settings:
auto_tag: true
auto_tag_suffix: windows-1809
daemon_off: true
dockerfile: docker/ecr/Dockerfile.windows.1809
password:
from_secret: docker_password
repo: plugins/ecr
username:
from_secret: docker_username
volumes:
- name: docker_pipe
path: \\\\.\\pipe\\docker_engine
when:
event:
exclude:
- pull_request
volumes:
- name: docker_pipe
host:
path: \\\\.\\pipe\\docker_engine
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- windows-1809-docker
---
kind: pipeline
name: notifications-ecr
platform:
os: windows
arch: amd64
version: 1809
steps:
- name: manifest
pull: always
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: docker/ecr/manifest.tmpl
username:
from_secret: docker_username
- name: microbadger
pull: always
image: plugins/webhook
settings:
urls:
from_secret: microbadger_ecr
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
depends_on:
- windows-1803-ecr
- windows-1809-ecr
...

View File

@@ -39,6 +39,120 @@ trigger:
- "refs/tags/**"
- "refs/pull/**"
---
kind: pipeline
type: ssh
name: windows-1809-amd64-docker
platform:
os: windows
server:
host: windows.1809.amd64.plugins.drone.ci
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
# TODO use the new DRONE_SEMVER_SHORT environment variables to
# publish docker images for tag events.
- go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/docker/Dockerfile.windows.1809 -t plugins/docker:windows-1809-amd64 .
- docker push plugins/docker:windows-1809-amd64
environment:
CGO_ENABLED: "0"
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
depends_on:
- testing
---
kind: pipeline
type: ssh
name: windows-1903-amd64-docker
platform:
os: windows
server:
host: windows.1903.amd64.plugins.drone.ci
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
# TODO use the new DRONE_SEMVER_SHORT environment variables to
# publish docker images for tag events.
- go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/docker/Dockerfile.windows.1903 -t plugins/docker:windows-1903-amd64 .
- docker push plugins/docker:windows-1903-amd64
environment:
CGO_ENABLED: "0"
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
depends_on:
- testing
---
kind: pipeline
type: ssh
name: windows-1909-amd64-docker
platform:
os: windows
server:
host: windows.1909.amd64.plugins.drone.ci
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
# TODO use the new DRONE_SEMVER_SHORT environment variables to
# publish docker images for tag events.
- go build -o release/windows/amd64/drone-docker.exe ./cmd/drone-docker
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/docker/Dockerfile.windows.1909 -t plugins/docker:windows-1909-amd64 .
- docker push plugins/docker:windows-1909-amd64
environment:
CGO_ENABLED: "0"
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
depends_on:
- testing
---
kind: pipeline
name: linux-amd64-docker
@@ -81,7 +195,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/docker/Dockerfile.linux.amd64
@@ -98,7 +212,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
@@ -165,7 +279,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/docker/Dockerfile.linux.arm64
@@ -182,7 +296,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
@@ -249,7 +363,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/docker/Dockerfile.linux.arm
@@ -266,7 +380,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
@@ -304,6 +418,7 @@ steps:
pull: always
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
@@ -314,6 +429,7 @@ steps:
- name: microbadger
pull: always
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: microbadger_docker
@@ -324,6 +440,9 @@ trigger:
- "refs/tags/**"
depends_on:
- windows-1809-amd64-docker
- windows-1903-amd64-docker
- windows-1909-amd64-docker
- linux-amd64-docker
- linux-arm64-docker
- linux-arm-docker
@@ -364,7 +483,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/gcr/Dockerfile.linux.amd64
@@ -381,7 +500,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
@@ -442,7 +561,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/gcr/Dockerfile.linux.arm64
@@ -459,7 +578,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
@@ -520,7 +639,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/gcr/Dockerfile.linux.arm
@@ -537,7 +656,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
@@ -575,6 +694,7 @@ steps:
pull: always
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
@@ -585,6 +705,7 @@ steps:
- name: microbadger
pull: always
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: microbadger_gcr
@@ -635,7 +756,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/ecr/Dockerfile.linux.amd64
@@ -652,7 +773,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
@@ -713,7 +834,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/ecr/Dockerfile.linux.arm64
@@ -730,7 +851,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
@@ -791,7 +912,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/ecr/Dockerfile.linux.arm
@@ -808,7 +929,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
@@ -846,6 +967,7 @@ steps:
pull: always
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
@@ -856,6 +978,7 @@ steps:
- name: microbadger
pull: always
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: microbadger_ecr
@@ -906,7 +1029,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/heroku/Dockerfile.linux.amd64
@@ -923,7 +1046,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-amd64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
@@ -984,7 +1107,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/heroku/Dockerfile.linux.arm64
@@ -1001,7 +1124,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm64
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
@@ -1062,7 +1185,7 @@ steps:
- name: dryrun
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/heroku/Dockerfile.linux.arm
@@ -1079,7 +1202,7 @@ steps:
- name: publish
pull: always
image: plugins/docker:linux-arm
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
@@ -1117,6 +1240,7 @@ steps:
pull: always
image: plugins/manifest
settings:
auto_tag: true
ignore_missing: true
password:
from_secret: docker_password
@@ -1127,6 +1251,7 @@ steps:
- name: microbadger
pull: always
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: microbadger_heroku
@@ -1141,4 +1266,277 @@ depends_on:
- linux-arm64-heroku
- linux-arm-heroku
---
kind: pipeline
name: linux-amd64-acr
platform:
os: linux
arch: amd64
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.amd64
dry_run: true
password:
from_secret: docker_password
repo: plugins/acr
tags: linux-amd64
username:
from_secret: docker_username
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-amd64
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.amd64
password:
from_secret: docker_password
repo: plugins/acr
username:
from_secret: docker_username
when:
event:
exclude:
- pull_request
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- linux-amd64-docker
---
kind: pipeline
name: linux-arm64-acr
platform:
os: linux
arch: arm64
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm64/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.arm64
dry_run: true
password:
from_secret: docker_password
repo: plugins/acr
tags: linux-arm64
username:
from_secret: docker_username
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm64
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.arm64
password:
from_secret: docker_password
repo: plugins/acr
username:
from_secret: docker_username
when:
event:
exclude:
- pull_request
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- linux-arm64-docker
---
kind: pipeline
name: linux-arm-acr
platform:
os: linux
arch: arm
steps:
- name: build-push
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
exclude:
- tag
- name: build-tag
pull: always
image: golang:1.11
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -tags netgo -o release/linux/arm/drone-acr ./cmd/drone-acr"
environment:
CGO_ENABLED: 0
GO111MODULE: on
when:
event:
- tag
- name: dryrun
pull: always
image: plugins/docker:18
settings:
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.arm
dry_run: true
password:
from_secret: docker_password
repo: plugins/acr
tags: linux-arm
username:
from_secret: docker_username
when:
event:
- pull_request
- name: publish
pull: always
image: plugins/docker:18
settings:
auto_tag: true
auto_tag_suffix: linux-arm
daemon_off: false
dockerfile: docker/acr/Dockerfile.linux.arm
password:
from_secret: docker_password
repo: plugins/acr
username:
from_secret: docker_username
when:
event:
exclude:
- pull_request
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
- "refs/pull/**"
depends_on:
- linux-arm-docker
---
kind: pipeline
name: notifications-acr
platform:
os: linux
arch: amd64
steps:
- name: manifest
pull: always
image: plugins/manifest
settings:
ignore_missing: true
password:
from_secret: docker_password
spec: docker/acr/manifest.tmpl
username:
from_secret: docker_username
- name: microbadger
pull: always
image: plugins/webhook
failure: ignore
settings:
url:
from_secret: microbadger_acr
trigger:
ref:
- refs/heads/master
- "refs/tags/**"
depends_on:
- linux-amd64-acr
- linux-arm64-acr
- linux-arm-acr
...

View File

@@ -8,7 +8,7 @@
[![Go Doc](https://godoc.org/github.com/drone-plugins/drone-docker?status.svg)](http://godoc.org/github.com/drone-plugins/drone-docker)
[![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-docker)](https://goreportcard.com/report/github.com/drone-plugins/drone-docker)
Drone plugin to build and publish Docker images to a container registry. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-docker/).
Drone plugin uses Docker-in-Docker to build and publish Docker images to a container registry. For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-docker/).
## Build
@@ -23,6 +23,7 @@ export GO111MODULE=on
go build -v -a -tags netgo -o release/linux/amd64/drone-docker ./cmd/drone-docker
go build -v -a -tags netgo -o release/linux/amd64/drone-gcr ./cmd/drone-gcr
go build -v -a -tags netgo -o release/linux/amd64/drone-ecr ./cmd/drone-ecr
go build -v -a -tags netgo -o release/linux/amd64/drone-acr ./cmd/drone-acr
go build -v -a -tags netgo -o release/linux/amd64/drone-heroku ./cmd/drone-heroku
```
@@ -46,6 +47,11 @@ docker build \
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
--file docker/ecr/Dockerfile.linux.amd64 --tag plugins/ecr .
docker build \
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
--file docker/acr/Dockerfile.linux.amd64 --tag plugins/acr .
docker build \
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \

60
cmd/drone-acr/main.go Normal file
View File

@@ -0,0 +1,60 @@
package main
import (
"fmt"
"os"
"os/exec"
"strings"
"github.com/joho/godotenv"
)
func main() {
// Load env-file if it exists first
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {
godotenv.Load(env)
}
var (
repo = getenv("PLUGIN_REPO")
registry = getenv("PLUGIN_REGISTRY")
username = getenv("SERVICE_PRINCIPAL_CLIENT_ID")
password = getenv("SERVICE_PRINCIPAL_CLIENT_SECRET")
)
// default registry value
if registry == "" {
registry = "azurecr.io"
}
// must use the fully qualified repo name. If the
// repo name does not have the registry prefix we
// should prepend.
if !strings.HasPrefix(repo, registry) {
repo = fmt.Sprintf("%s/%s", registry, repo)
}
os.Setenv("PLUGIN_REPO", repo)
os.Setenv("PLUGIN_REGISTRY", registry)
os.Setenv("DOCKER_USERNAME", username)
os.Setenv("DOCKER_PASSWORD", password)
// invoke the base docker plugin binary
cmd := exec.Command("drone-docker")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
os.Exit(1)
}
}
func getenv(key ...string) (s string) {
for _, k := range key {
s = os.Getenv(k)
if s != "" {
return
}
}
return
}

View File

@@ -7,7 +7,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/drone-plugins/drone-docker"
docker "github.com/drone-plugins/drone-docker"
)
var (
@@ -147,6 +147,11 @@ func main() {
Usage: "build args",
EnvVar: "PLUGIN_BUILD_ARGS_FROM_ENV",
},
cli.BoolFlag{
Name: "quiet",
Usage: "quiet docker build",
EnvVar: "PLUGIN_QUIET",
},
cli.StringFlag{
Name: "target",
Usage: "build target",
@@ -208,6 +213,11 @@ func main() {
Usage: "docker email",
EnvVar: "PLUGIN_EMAIL,DOCKER_EMAIL",
},
cli.StringFlag{
Name: "docker.config",
Usage: "docker json dockerconfig content",
EnvVar: "PLUGIN_CONFIG",
},
cli.BoolTFlag{
Name: "docker.purge",
Usage: "docker should cleanup images",
@@ -223,6 +233,11 @@ func main() {
Usage: "do not use cached intermediate containers",
EnvVar: "PLUGIN_NO_CACHE",
},
cli.StringSliceFlag{
Name: "add-host",
Usage: "additional host:IP mapping",
EnvVar: "PLUGIN_ADD_HOST",
},
}
if err := app.Run(os.Args); err != nil {
@@ -239,6 +254,7 @@ func run(c *cli.Context) error {
Username: c.String("docker.username"),
Password: c.String("docker.password"),
Email: c.String("docker.email"),
Config: c.String("docker.config"),
},
Build: docker.Build{
Remote: c.String("remote.url"),
@@ -257,6 +273,8 @@ func run(c *cli.Context) error {
Labels: c.StringSlice("custom-labels"),
LabelSchema: c.StringSlice("label-schema"),
NoCache: c.Bool("no-cache"),
AddHost: c.StringSlice("add-host"),
Quiet: c.Bool("quiet"),
},
Daemon: docker.Daemon{
Registry: c.String("docker.registry"),
@@ -280,10 +298,15 @@ func run(c *cli.Context) error {
c.String("commit.ref"),
c.String("repo.branch"),
) {
plugin.Build.Tags = docker.DefaultTagSuffix(
tag, err := docker.DefaultTagSuffix(
c.String("commit.ref"),
c.String("tags.suffix"),
)
if err != nil {
logrus.Printf("cannot build docker image for %s, invalid semantic version", c.String("commit.ref"))
return err
}
plugin.Build.Tags = tag
} else {
logrus.Printf("skipping automated docker build for %s", c.String("commit.ref"))
return nil

View File

@@ -10,8 +10,11 @@ import (
"strconv"
"strings"
"github.com/joho/godotenv"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ecr"
)
@@ -19,14 +22,21 @@ import (
const defaultRegion = "us-east-1"
func main() {
// Load env-file if it exists first
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {
godotenv.Load(env)
}
var (
repo = getenv("PLUGIN_REPO")
registry = getenv("PLUGIN_REGISTRY")
region = getenv("PLUGIN_REGION", "ECR_REGION", "AWS_REGION")
key = getenv("PLUGIN_ACCESS_KEY", "ECR_ACCESS_KEY", "AWS_ACCESS_KEY_ID")
secret = getenv("PLUGIN_SECRET_KEY", "ECR_SECRET_KEY", "AWS_SECRET_ACCESS_KEY")
create = parseBoolOrDefault(false, getenv("PLUGIN_CREATE_REPOSITORY", "ECR_CREATE_REPOSITORY"))
lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY")
repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY")
assumeRole = getenv("PLUGIN_ASSUME_ROLE")
)
// set the region
@@ -42,13 +52,17 @@ func main() {
}
sess, err := session.NewSession(&aws.Config{Region: &region})
if err != nil {
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
}
svc := ecr.New(sess)
username, password, registry, err := getAuthInfo(svc)
svc := getECRClient(sess, assumeRole)
username, password, defaultRegistry, err := getAuthInfo(svc)
if registry == "" {
registry = defaultRegistry
}
if err != nil {
log.Fatal(fmt.Sprintf("error getting ECR auth: %v", err))
}
@@ -178,3 +192,12 @@ func getenv(key ...string) (s string) {
}
return
}
func getECRClient(sess *session.Session, role string) *ecr.ECR {
if role == "" {
return ecr.New(sess)
}
return ecr.New(sess, &aws.Config{
Credentials: stscreds.NewCredentials(sess, role),
})
}

View File

@@ -6,12 +6,19 @@ import (
"os/exec"
"path"
"strings"
"github.com/joho/godotenv"
)
// gcr default username
const username = "_json_key"
func main() {
// Load env-file if it exists first
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {
godotenv.Load(env)
}
var (
repo = getenv("PLUGIN_REPO")
registry = getenv("PLUGIN_REGISTRY")

View File

@@ -4,9 +4,16 @@ import (
"os"
"os/exec"
"path"
"github.com/joho/godotenv"
)
func main() {
// Load env-file if it exists first
if env := os.Getenv("PLUGIN_ENV_FILE"); env != "" {
godotenv.Load(env)
}
var (
registry = "registry.heroku.com"
process = getenv("PLUGIN_PROCESS_TYPE")

27
daemon.go Normal file
View File

@@ -0,0 +1,27 @@
// +build !windows
package docker
import (
"io/ioutil"
"os"
)
const dockerExe = "/usr/local/bin/docker"
const dockerdExe = "/usr/local/bin/dockerd"
const dockerHome = "/root/.docker/"
func (p Plugin) startDaemon() {
cmd := commandDaemon(p.Daemon)
if p.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
}
go func() {
trace(cmd)
cmd.Run()
}()
}

11
daemon_win.go Normal file
View File

@@ -0,0 +1,11 @@
// +build windows
package docker
const dockerExe = "C:\\bin\\docker.exe"
const dockerdExe = ""
const dockerHome = "C:\\ProgramData\\docker\\"
func (p Plugin) startDaemon() {
// this is a no-op on windows
}

View File

@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)
@@ -33,6 +34,7 @@ type (
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.
@@ -53,6 +55,8 @@ type (
LabelSchema []string // label-schema Label map
Labels []string // Label map
NoCache bool // Docker build no-cache
AddHost []string // Docker build add-host
Quiet bool // Docker build quiet
}
// Plugin defines the Docker plugin parameters.
@@ -69,18 +73,7 @@ type (
func (p Plugin) Exec() error {
// start the Docker daemon server
if !p.Daemon.Disabled {
cmd := commandDaemon(p.Daemon)
if p.Daemon.Debug {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
} else {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
}
go func() {
trace(cmd)
cmd.Run()
}()
p.startDaemon()
}
// poll the docker daemon until it is started. This ensures the daemon is
@@ -94,6 +87,17 @@ func (p Plugin) Exec() error {
time.Sleep(time.Second * 1)
}
// Create Auth Config File
if p.Login.Config != "" {
os.MkdirAll(dockerHome, 0600)
path := filepath.Join(dockerHome, "config.json")
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
if err != nil {
return fmt.Errorf("Error writeing config.json: %s", err)
}
}
// login to the Docker registry
if p.Login.Password != "" {
cmd := commandLogin(p.Login)
@@ -101,8 +105,15 @@ func (p Plugin) Exec() error {
if err != nil {
return fmt.Errorf("Error authenticating: %s", err)
}
} else {
fmt.Println("Registry credentials not provided. Guest mode enabled.")
}
switch {
case p.Login.Password != "":
fmt.Println("Detected registry credentials")
case p.Login.Config != "":
fmt.Println("Detected registry credentials file")
default:
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
}
if p.Build.Squash && !p.Daemon.Experimental {
@@ -146,6 +157,10 @@ func (p Plugin) Exec() error {
err := cmd.Run()
if 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) {
fmt.Printf("Could not prune system containers. Ignoring...\n")
} else if err != nil && isCommandRmi(cmd.Args) {
fmt.Printf("Could not remove image %s. Ignoring...\n", cmd.Args[2])
} else if err != nil {
return err
}
@@ -154,9 +169,6 @@ func (p Plugin) Exec() error {
return nil
}
const dockerExe = "/usr/local/bin/docker"
const dockerdExe = "/usr/local/bin/dockerd"
// helper function to create the docker login command.
func commandLogin(login Login) *exec.Cmd {
if login.Email != "" {
@@ -230,9 +242,15 @@ func commandBuild(build Build) *exec.Cmd {
for _, arg := range build.Args {
args = append(args, "--build-arg", arg)
}
for _, host := range build.AddHost {
args = append(args, "--add-host", host)
}
if build.Target != "" {
args = append(args, "--target", build.Target)
}
if build.Quiet {
args = append(args, "--quiet")
}
labelSchema := []string{
"schema-version=1.0",
@@ -320,7 +338,10 @@ func commandPush(build Build, tag string) *exec.Cmd {
// helper function to create the docker daemon command.
func commandDaemon(daemon Daemon) *exec.Cmd {
args := []string{"--data-root", daemon.StoragePath}
args := []string{
"--data-root", daemon.StoragePath,
"--host=unix:///var/run/docker.sock",
}
if daemon.StorageDriver != "" {
args = append(args, "-s", daemon.StorageDriver)
@@ -352,10 +373,21 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
return exec.Command(dockerdExe, args...)
}
// helper to check if args match "docker prune"
func isCommandPrune(args []string) bool {
return len(args) > 3 && args[2] == "prune"
}
func commandPrune() *exec.Cmd {
return exec.Command(dockerExe, "system", "prune", "-f")
}
// helper to check if args match "docker rmi"
func isCommandRmi(args []string) bool {
return len(args) > 2 && args[1] == "rmi"
}
func commandRmi(tag string) *exec.Cmd {
return exec.Command(dockerExe, "rmi", tag)
}

View File

@@ -0,0 +1,4 @@
FROM plugins/docker:linux-amd64
ADD release/linux/amd64/drone-acr /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-acr"]

View File

@@ -0,0 +1,4 @@
FROM plugins/docker:linux-arm
ADD release/linux/arm/drone-acr /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-acr"]

View File

@@ -0,0 +1,4 @@
FROM plugins/docker:linux-arm64
ADD release/linux/arm64/drone-acr /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-acr"]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-1809-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ACR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-1903-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ACR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-1909-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ACR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-2004-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ACR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-acr.exe C:/bin/drone-acr.exe
ENTRYPOINT [ "C:\\bin\\drone-acr.exe" ]

44
docker/acr/manifest.tmpl Normal file
View File

@@ -0,0 +1,44 @@
image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
platform:
architecture: amd64
os: windows
version: 2004
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
- image: plugins/acr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows
version: 1809

View File

@@ -1,4 +1,6 @@
FROM docker:18.06-dind
FROM docker:19.03.8-dind
ENV DOCKER_HOST=unix:///var/run/docker.sock
ADD release/linux/amd64/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]

View File

@@ -1,4 +1,6 @@
FROM arm32v6/docker:18.06-dind
FROM arm32v6/docker:19.03.8-dind
ENV DOCKER_HOST=unix:///var/run/docker.sock
ADD release/linux/arm/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]

View File

@@ -1,4 +1,6 @@
FROM arm64v8/docker:18.06-dind
FROM arm64v8/docker:19.03.8-dind
ENV DOCKER_HOST=unix:///var/run/docker.sock
ADD release/linux/arm64/drone-docker /bin/
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]

View File

@@ -3,9 +3,9 @@ FROM mcr.microsoft.com/windows/servercore:1809 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV DOCKER_VERSION 18.09.1
ENV DOCKER_VERSION 19.03.1
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.6-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.9-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
Remove-Item -Path innoextract.zip
@@ -13,7 +13,8 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
RUN /innoextract.exe dockertoolbox.exe
FROM plugins/base:windows-1809
FROM plugins/base:windows-1809-amd64
USER ContainerAdministrator
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Docker" `

View File

@@ -1,11 +1,11 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1803 as download
FROM mcr.microsoft.com/windows/servercore:1903 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV DOCKER_VERSION 18.09.1
ENV DOCKER_VERSION 19.03.1
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.6-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.9-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
Remove-Item -Path innoextract.zip
@@ -13,7 +13,8 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
RUN /innoextract.exe dockertoolbox.exe
FROM plugins/base:windows-1803
FROM plugins/base:windows-1903-amd64
USER ContainerAdministrator
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Docker" `

View File

@@ -0,0 +1,27 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1909 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV DOCKER_VERSION 19.03.1
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.9-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
Remove-Item -Path innoextract.zip
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
RUN /innoextract.exe dockertoolbox.exe
FROM plugins/base:windows-1909-amd64
USER ContainerAdministrator
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Docker" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
COPY --from=download /app/docker.exe C:/bin/docker.exe
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]

View File

@@ -0,0 +1,27 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:2004 as download
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV DOCKER_VERSION 19.03.1
RUN Invoke-WebRequest 'http://constexpr.org/innoextract/files/innoextract-1.9-windows.zip' -OutFile 'innoextract.zip' -UseBasicParsing ; `
Expand-Archive innoextract.zip -DestinationPath C:\ ; `
Remove-Item -Path innoextract.zip
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://github.com/docker/toolbox/releases/download/v{0}/DockerToolbox-{0}.exe' -f $env:DOCKER_VERSION) -OutFile 'dockertoolbox.exe' -UseBasicParsing
RUN /innoextract.exe dockertoolbox.exe
FROM plugins/base:windows-2004-amd64
USER ContainerAdministrator
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone Docker" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
COPY --from=download /windows/system32/netapi32.dll /windows/system32/netapi32.dll
COPY --from=download /app/docker.exe C:/bin/docker.exe
ADD release/windows/amd64/drone-docker.exe C:/bin/drone-docker.exe
ENTRYPOINT [ "C:\\bin\\drone-docker.exe" ]

View File

@@ -1,36 +1,43 @@
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
-
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7
-
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
platform:
architecture: amd64
os: windows
version: 1803
-
image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
version: 2004
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
- image: plugins/docker:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows

View File

@@ -1,5 +1,5 @@
# escape=`
FROM plugins/docker:windows-1809
FROM plugins/docker:windows-1809-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ECR" `

View File

@@ -1,5 +1,5 @@
# escape=`
FROM plugins/docker:windows-1803
FROM plugins/docker:windows-1903-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ECR" `

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-1909-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ECR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-ecr.exe C:/bin/drone-ecr.exe
ENTRYPOINT [ "C:\\bin\\drone-ecr.exe" ]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-2004-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone ECR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-ecr.exe C:/bin/drone-ecr.exe
ENTRYPOINT [ "C:\\bin\\drone-ecr.exe" ]

View File

@@ -1,36 +1,43 @@
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
-
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7
-
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
platform:
architecture: amd64
os: windows
version: 1803
-
image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
version: 2004
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
- image: plugins/ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows

View File

@@ -1,5 +1,5 @@
# escape=`
FROM plugins/docker:windows-1809
FROM plugins/docker:windows-1809-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone GCR" `

View File

@@ -1,5 +1,5 @@
# escape=`
FROM plugins/docker:windows-1803
FROM plugins/docker:windows-1903-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone GCR" `

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-1909-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone GCR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-gcr.exe C:/bin/drone-gcr.exe
ENTRYPOINT [ "C:\\bin\\drone-gcr.exe" ]

View File

@@ -0,0 +1,10 @@
# escape=`
FROM plugins/docker:windows-2004-amd64
LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" `
org.label-schema.name="Drone GCR" `
org.label-schema.vendor="Drone.IO Community" `
org.label-schema.schema-version="1.0"
ADD release/windows/amd64/drone-gcr.exe C:/bin/drone-gcr.exe
ENTRYPOINT [ "C:\\bin\\drone-gcr.exe" ]

View File

@@ -1,36 +1,43 @@
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
-
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux
variant: v7
-
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-2004-amd64
platform:
architecture: amd64
os: windows
version: 1803
-
image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809
version: 2004
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
platform:
architecture: amd64
os: windows
version: 1903
- image: plugins/gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
architecture: amd64
os: windows

View File

@@ -1,24 +1,23 @@
image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
-
image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
- image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
- image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
-
image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
- image: plugins/heroku:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
architecture: arm
os: linux

7
go.mod
View File

@@ -1,14 +1,13 @@
module github.com/drone-plugins/drone-docker
require (
github.com/aws/aws-sdk-go v1.16.15
github.com/aws/aws-sdk-go v1.26.7
github.com/coreos/go-semver v0.2.0
github.com/joho/godotenv v1.3.0
github.com/sirupsen/logrus v1.3.0
github.com/urfave/cli v1.20.0
github.com/urfave/cli v1.22.2
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
replace github.com/urfave/cli => github.com/bradrydzewski/cli v0.0.0-20190108225652-0d51abd87c77
go 1.13

15
go.sum
View File

@@ -1,9 +1,10 @@
github.com/aws/aws-sdk-go v1.16.15 h1:kQyxfRyjAwIYjf0225sn/pn+WAlncKyI8dmT3+ItMFE=
github.com/aws/aws-sdk-go v1.16.15/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/bradrydzewski/cli v0.0.0-20190108225652-0d51abd87c77 h1:bXc5tB7PFVzIHUfTECDt0Orw6mIAzHePWBmemvtnfiU=
github.com/bradrydzewski/cli v0.0.0-20190108225652-0d51abd87c77/go.mod h1:4SmsVk3pOgYeJlG54e23Ztd/HucXeH5RmH5bNO+uOpk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/aws/aws-sdk-go v1.26.7 h1:ObjEnmzvSdYy8KVd3me7v/UMyCn81inLy2SyoIPoBkg=
github.com/aws/aws-sdk-go v1.26.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
github.com/coreos/go-semver v0.2.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/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/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
@@ -14,6 +15,10 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGi
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
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/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.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -21,6 +26,8 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=

View File

@@ -183,6 +183,7 @@ local golang_image(os, version) =
password: { from_secret: 'docker_password' },
spec: 'docker/' + name + '/manifest.tmpl',
ignore_missing: true,
auto_tag: true,
},
},
{

23
tags.go
View File

@@ -9,10 +9,13 @@ import (
// DefaultTagSuffix returns a set of default suggested tags
// based on the commit ref with an attached suffix.
func DefaultTagSuffix(ref, suffix string) []string {
tags := DefaultTags(ref)
func DefaultTagSuffix(ref, suffix string) ([]string, error) {
tags, err := DefaultTags(ref)
if err != nil {
return nil, err
}
if len(suffix) == 0 {
return tags
return tags, nil
}
for i, tag := range tags {
if tag == "latest" {
@@ -21,7 +24,7 @@ func DefaultTagSuffix(ref, suffix string) []string {
tags[i] = fmt.Sprintf("%s-%s", tag, suffix)
}
}
return tags
return tags, nil
}
func splitOff(input string, delim string) string {
@@ -36,19 +39,19 @@ func splitOff(input string, delim string) string {
// DefaultTags returns a set of default suggested tags based on
// the commit ref.
func DefaultTags(ref string) []string {
func DefaultTags(ref string) ([]string, error) {
if !strings.HasPrefix(ref, "refs/tags/") {
return []string{"latest"}
return []string{"latest"}, nil
}
v := stripTagPrefix(ref)
version, err := semver.NewVersion(v)
if err != nil {
return []string{"latest"}
return []string{"latest"}, err
}
if version.PreRelease != "" || version.Metadata != "" {
return []string{
version.String(),
}
}, nil
}
v = stripTagPrefix(ref)
@@ -59,13 +62,13 @@ func DefaultTags(ref string) []string {
return []string{
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
}
}, nil
}
return []string{
fmt.Sprintf("%0*d", len(dotParts[0]), version.Major),
fmt.Sprintf("%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor),
fmt.Sprintf("%0*d.%0*d.%0*d", len(dotParts[0]), version.Major, len(dotParts[1]), version.Minor, len(dotParts[2]), version.Patch),
}
}, nil
}
// UseDefaultTag for keep only default branch for latest tag

View File

@@ -34,20 +34,35 @@ func TestDefaultTags(t *testing.T) {
{"refs/tags/1.0.0", []string{"1", "1.0", "1.0.0"}},
{"refs/tags/v1.0.0", []string{"1", "1.0", "1.0.0"}},
{"refs/tags/v1.0.0-alpha.1", []string{"1.0.0-alpha.1"}},
// malformed or errors
{"refs/tags/x1.0.0", []string{"latest"}},
{"v1.0.0", []string{"latest"}},
}
for _, test := range tests {
got, want := DefaultTags(test.Before), test.After
tags, err := DefaultTags(test.Before)
if err != nil {
t.Error(err)
continue
}
got, want := tags, test.After
if !reflect.DeepEqual(got, want) {
t.Errorf("Got tag %v, want %v", got, want)
}
}
}
func TestDefaultTagsError(t *testing.T) {
var tests = []string{
"refs/tags/x1.0.0",
"refs/tags/20190203",
}
for _, test := range tests {
_, err := DefaultTags(test)
if err == nil {
t.Errorf("Expect tag error for %s", test)
}
}
}
func TestDefaultTagSuffix(t *testing.T) {
var tests = []struct {
Before string
@@ -105,7 +120,12 @@ func TestDefaultTagSuffix(t *testing.T) {
}
for _, test := range tests {
got, want := DefaultTagSuffix(test.Before, test.Suffix), test.After
tag, err := DefaultTagSuffix(test.Before, test.Suffix)
if err != nil {
t.Error(err)
continue
}
got, want := tag, test.After
if !reflect.DeepEqual(got, want) {
t.Errorf("Got tag %v, want %v", got, want)
}