-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
118 lines (108 loc) · 2.75 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
kind: pipeline
type: kubernetes
name: default
volumes:
- name: docker-socket
host:
path: /var/run/
- name: docker-config
host:
path: /home/chris/.docker/
docker: &docker
image: docker:dind
volumes:
- name: docker-socket
path: /var/run/
- name: docker-config
path: /root/.docker/
environment:
REGISTRY: registry.home.theguidrys.us
IMAGE_NAME: 44stonypoint/skim
IMAGE_TAG: "${DRONE_COMMIT_BRANCH}-${DRONE_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:8}"
steps:
- name: build
<<: *docker
environment:
DOCKER_BUILDKIT: "1"
commands:
- |
docker build \
--pull \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from $REGISTRY/$IMAGE_NAME:latest \
-t $IMAGE_NAME:$IMAGE_TAG \
.
- name: test
<<: *docker
commands:
- |
docker run \
-d \
-e POSTGRES_DB=skim \
-e POSTGRES_USER=skim \
-e POSTGRES_PASSWORD=skim-password \
--tmpfs /var/lib/postgresql/data \
--name postgres-$IMAGE_TAG \
postgres:14.2
- |
docker run \
--rm \
--link postgres-$IMAGE_TAG:database \
-e DB_HOST=database \
-e DB_USER=skim \
-e DB_PASSWORD=skim-password \
-e DB_NAME=skim \
-e OTEL_RESOURCE_ATTRIBUTES=service.name=skim.tests \
-e OTEL_EXPORTER_OTLP_ENDPOINT=http://collector.home.theguidrys.us:4317 \
-e OTEL_EXPORTER_OTLP_INSECURE=true \
--entrypoint=/usr/local/bin/opentelemetry-instrument \
$IMAGE_NAME:$IMAGE_TAG \
/usr/local/bin/pytest --export-traces
- name: publish
<<: *docker
commands:
- docker tag $IMAGE_NAME:$IMAGE_TAG $REGISTRY/$IMAGE_NAME:$IMAGE_TAG
- docker tag $IMAGE_NAME:$IMAGE_TAG $REGISTRY/$IMAGE_NAME:latest
- docker push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG
- docker push $REGISTRY/$IMAGE_NAME:latest
- docker rmi $REGISTRY/$IMAGE_NAME:$IMAGE_TAG
# we'll leave the :latest so we have better layer cache re-use
when:
branch:
- main
- name: deploy
image: registry.home.theguidrys.us/44stonypoint/k8s-deploy
volumes:
- name: docker-socket
path: /var/run/
- name: docker-config
path: /root/.docker/
pull: always
commands:
- /44stonypoint/k8s/deploy skim $REGISTRY/$IMAGE_NAME:latest=$REGISTRY/$IMAGE_NAME:$IMAGE_TAG
when:
branch:
- main
- name: cleanup
<<: *docker
when:
status:
- success
- failure
commands:
- docker rm -f postgres-$IMAGE_TAG
- docker rmi $IMAGE_NAME:$IMAGE_TAG
- name: notify
image: registry.home.theguidrys.us/44stonypoint/drone-pushover
pull: always
when:
status:
- failure
environment:
# compensating for weird behavior, it was always sending success
DRONE_BUILD_STATUS: failure
settings:
pushover_token:
from_secret: pushover_token
pushover_user:
from_secret: pushover_user