-
Notifications
You must be signed in to change notification settings - Fork 8
/
.drone.yml
187 lines (171 loc) · 5.32 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
---
kind: pipeline
type: docker
name: build-master
clone:
depth: 50
platform:
os: linux
arch: amd64
# Set the project as Trusted in Drone project settings to let it use volumes
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
- name: cache-docker-buildx-0.5.1
host:
path: /tmp/drone/cache/docker-buildx-0.5.1
steps:
# Multi-platform build, downloading buildx only when not cached
# @see: https://docs.drone.io/pipeline/docker/examples/services/docker/
- name: build-docker
image: docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: cache-docker-buildx-0.5.1
path: /root/.docker/cli-plugins
environment:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKERHUB_PASSWORD:
from_secret: dockerhub_kubekarp_access_token
QUAY_PASSWORD:
from_secret: quay_kubekarp_encrypted_pass
HARBOR_FQDN:
from_secret: harbor_registry_fqdn
HARBOR_REPO:
from_secret: harbor_repo
HARBOR_USERNAME:
from_secret: harbor_robot_kubekarp_push_username
HARBOR_PASSWORD:
from_secret: harbor_robot_kubekarp_push_password
commands:
- |
(
set -x; \
FILE=~/.docker/cli-plugins/docker-buildx; \
[ ! -f $FILE ] && \
wget -O $FILE https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 \
&& chmod +x $FILE \
|| true
)
- docker login --username immanuelfodor --password "$DOCKERHUB_PASSWORD"
- docker login --username immanuelfodor --password "$QUAY_PASSWORD" quay.io
- docker login $HARBOR_FQDN --username "$HARBOR_USERNAME" --password "$HARBOR_PASSWORD"
- docker buildx create --use
- |
docker buildx build \
--platform linux/arm,linux/arm64,linux/amd64 \
--tag $HARBOR_REPO:${DRONE_COMMIT_SHA:0:10}-${DRONE_BUILD_NUMBER} \
--tag $HARBOR_REPO:master \
--tag immanuelfodor/kube-karp:master \
--tag quay.io/immanuelfodor/kube-karp:master \
--push \
.
# @see: http://plugins.drone.io/drone-plugins/drone-webhook/
# @see: https://keel.sh/docs/#webhooks
- name: deploy-k8s
image: plugins/webhook
settings:
urls:
from_secret: keel_webhook_url
content_type: application/json
template:
from_secret: keel_native_payload_repo_tag_commit
# @see: http://plugins.drone.io/drone-plugins/drone-webhook/
# @see: https://github.com/drone-plugins/drone-webhook/blob/master/plugin.go
- name: notify-done
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: done_webhook_url
content_type: application/json
template: |
{
"build": "#{{ build.number }} {{ build.status }} @ {{ repo.owner }}/{{ repo.name }} on branch {{ build.branch }}",
"message": "{{ trim build.message }}",
"url": "{{ build.link }}",
"commit": "{{ truncate build.commit 10 }}"
}
trigger:
branch:
- master
event:
- push
---
kind: pipeline
type: docker
name: build-tag
clone:
depth: 50
platform:
os: linux
arch: amd64
# Set the project as Trusted in Drone project settings to let it use volumes
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
- name: cache-docker-buildx-0.5.1
host:
path: /tmp/drone/cache/docker-buildx-0.5.1
steps:
# Multi-platform build, downloading buildx only when not cached
# @see: https://docs.drone.io/pipeline/docker/examples/services/docker/
- name: build-docker
image: docker:dind
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: cache-docker-buildx-0.5.1
path: /root/.docker/cli-plugins
environment:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKERHUB_PASSWORD:
from_secret: dockerhub_kubekarp_access_token
QUAY_PASSWORD:
from_secret: quay_kubekarp_encrypted_pass
commands:
- |
(
set -x; \
FILE=~/.docker/cli-plugins/docker-buildx; \
[ ! -f $FILE ] && \
wget -O $FILE https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 \
&& chmod +x $FILE \
|| true
)
- docker login --username immanuelfodor --password "$DOCKERHUB_PASSWORD"
- docker login --username immanuelfodor --password "$QUAY_PASSWORD" quay.io
- docker buildx create --use
- |
docker buildx build \
--platform linux/arm,linux/arm64,linux/amd64 \
--tag immanuelfodor/kube-karp:$DRONE_TAG \
--tag immanuelfodor/kube-karp:$(echo "${DRONE_TAG}" | cut -d'.' -f 1-2) \
--tag immanuelfodor/kube-karp:$(echo "${DRONE_TAG}" | cut -d'.' -f 1) \
--tag quay.io/immanuelfodor/kube-karp:$DRONE_TAG \
--tag quay.io/immanuelfodor/kube-karp:$(echo "${DRONE_TAG}" | cut -d'.' -f 1-2) \
--tag quay.io/immanuelfodor/kube-karp:$(echo "${DRONE_TAG}" | cut -d'.' -f 1) \
--push \
.
# @see: http://plugins.drone.io/drone-plugins/drone-webhook/
# @see: https://github.com/drone-plugins/drone-webhook/blob/master/plugin.go
- name: notify-done
image: plugins/webhook
failure: ignore
settings:
urls:
from_secret: done_webhook_url
content_type: application/json
template: |
{
"build": "#{{ build.number }} {{ build.status }} @ {{ repo.owner }}/{{ repo.name }} on tag {{ build.tag }}",
"message": "{{ trim build.message }}",
"url": "{{ build.link }}",
"commit": "{{ truncate build.commit 10 }}"
}
trigger:
event:
- tag