-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.drone.yml
146 lines (126 loc) · 3.55 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
# Utilities
docker_volumes: &docker_volumes
volumes:
- name: docker
path: /var/run/docker.sock
- name: pip_cache
path: /root/.cache/pip
- name: ecr_helper
path: /usr/local/bin/docker-credential-ecr-login
when_prod: &when_prod
when:
ref:
- refs/tags/*
when_stage: &when_stage
when:
ref:
include:
- refs/heads/main
exclude:
- refs/tags/*
when_dev: &when_dev
when:
ref:
exclude:
- refs/tags/*
- refs/heads/main
# ECR build
ecr_build: &ecr_build
image: plugins/ecr
settings:
dockerfile: ./Dockerfile
build_args:
- BUILD_TARGET=databricks
create_repository: true
repo: <aws-account>.dkr.ecr.<aws-region>.amazonaws.com/<image-name>
registry: <aws-account>.dkr.ecr.<aws-region>.amazonaws.com
region: <aws-region>
########################################################################################################################
### Drone CI/CD pipeline
########################################################################################################################
kind: pipeline
name: default
steps:
### Build step
- name: ecr_build_prod
<<: *ecr_build
settings:
tags:
- latest
- ${DRONE_TAG}
<<: *when_prod
- name: ecr_build_stage
<<: *ecr_build
settings:
tags:
- stage
<<: *when_stage
- name: ecr_build_dev
<<: *ecr_build
settings:
tags:
- ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}
<<: *when_dev
### Deployment step
- name: spark_deploy_prod
image: alpine:3.7
environment:
DATABRICKS_API_TOKEN:
from_secret: databricks_api_token
CLUSTER_NAME: PROD_SPARK_DEMO
IMAGE_NAME: "${DRONE_REPO_NAME}:${DRONE_TAG}"
ENV_FOR_DYNACONF: production
INIT_SCRIPTS_DESTINATION_S3: s3://<your-s3-bucket>--prod/init_scripts/init-script.sh
LOG_DESTINATION_S3: s3://<your-s3-bucket>--prod/${DRONE_REPO_NAME}/logs
INSTANCE_TYPE: c5.xlarge
SPARK_VERSION: 7.3.x-scala2.12
MIN_WORKERS: 1
MAX_WORKERS: 100
commands:
- apk update && apk add --no-cache curl jq
- sh deploy/databricks/deploy-job.sh
<<: *when_prod
- name: spark_deploy_stage
image: alpine:3.7
environment:
DATABRICKS_API_TOKEN:
from_secret: databricks_api_token
CLUSTER_NAME: STAGE_SPARK_DEMO
IMAGE_NAME: "${DRONE_REPO_NAME}:stage"
ENV_FOR_DYNACONF: staging
INIT_SCRIPTS_DESTINATION_S3: s3://<your-s3-bucket>--stage/init_scripts/init-script.sh
LOG_DESTINATION_S3: s3://<your-s3-bucket>--stage/${DRONE_REPO_NAME}/logs
INSTANCE_TYPE: c5.xlarge
SPARK_VERSION: 7.3.x-scala2.12
MIN_WORKERS: 1
MAX_WORKERS: 2
commands:
- apk update && apk add --no-cache curl jq
- sh deploy/databricks/deploy-job.sh
<<: *when_stage
### Notification
- name: notify
image: plugins/slack
settings:
channel: <your-slack-channel>
webhook: https://hooks.slack.com/services/<your-slack-hook-token>
username: "Drone"
template: |
{{#success build.status}}
{{ build.link }} {{ build.author }} successfully pushed to {{ build.branch }}
{{else}}
{{ build.link }} {{ build.author }} broke the build.
{{/success}}
when:
status: [success, failure]
### Volumes section
volumes:
- name: docker
host:
path: /var/run/docker.sock
- name: pip_cache
host:
path: /root/.cache/pip
- name: ecr_helper
host:
path: /usr/local/bin/docker-credential-ecr-login