Repository navigation
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
283 lines (271 loc) · 9.15 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
283 lines (271 loc) · 9.15 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# Production Docker Compose stack for AlertFlow.
#
# Usage (Coolify):
# New Resource -> Docker Compose (Git based)
# - Docker Compose Location: /docker-compose.yaml
# - Set the required variables (marked with ${VAR:?}) in the Coolify UI:
# AIRFLOW__CORE__FERNET_KEY, AIRFLOW__CORE__INTERNAL_API_SECRET_KEY,
# AIRFLOW__WEBSERVER__SECRET_KEY, AIRFLOW__API_AUTH__JWT_SECRET,
# _AIRFLOW_WWW_USER_USERNAME, _AIRFLOW_WWW_USER_PASSWORD, plus the
# PSQL_*/CDSAPI_KEY/PYSUS_* values used by the DAGs.
# - In the Coolify UI, set the `airflow-apiserver` service's Domains field to
# https://alertflow.dengue.mat.br:8081 (the suffix is the internal container
# port) and set AIRFLOW__WEBSERVER__BASE_URL=https://alertflow.dengue.mat.br.
# Coolify generates the proxy labels and TLS certificate automatically, so the
# service is routed by hostname instead of a path prefix.
#
# Usage (standalone):
# docker compose up -d
---
x-airflow-common: &airflow-common
build:
context: .
dockerfile: Dockerfile
args:
HOST_UID: ${HOST_UID:-1000}
HOST_GID: ${HOST_GID:-1000}
image: alertflow:${ALERTFLOW_IMAGE_TAG:-latest}
environment: &airflow-common-env
HOST_UID: ${HOST_UID:-1000}
HOST_GID: ${HOST_GID:-1000}
AIRFLOW_UID: ${HOST_UID:-1000}
AIRFLOW_PORT: ${AIRFLOW_PORT:-8080}
AIRFLOW_HOME: /opt/airflow
AIRFLOW_VAR_PSQL_MAIN_URI: '{"PSQL_MAIN_URI":"${PSQL_URI_MAIN}"}'
AIRFLOW_VAR_CDSAPI_KEY: '{"CDSAPI_KEY":"${CDSAPI_KEY}"}'
AIRFLOW_VAR_PYSUS_S3_ACCESS_KEY: '{"PYSUS_S3_ACCESS_KEY":"${PYSUS_S3_ACCESS_KEY}"}'
AIRFLOW_VAR_PYSUS_S3_SECRET_KEY: '{"PYSUS_S3_SECRET_KEY":"${PYSUS_S3_SECRET_KEY}"}'
AIRFLOW_VAR_PYSUS_DADOSGOV_TOKEN: '{"PYSUS_DADOSGOV_TOKEN":"${PYSUS_DADOSGOV_TOKEN}"}'
# --
AIRFLOW__SMTP__SMTP_HOST: ${AIRFLOW__SMTP__SMTP_HOST:-''}
AIRFLOW__SMTP__SMTP_STARTTLS: ${AIRFLOW__SMTP__SMTP_STARTTLS:-true}
AIRFLOW__SMTP__SMTP_PORT: ${AIRFLOW__SMTP__SMTP_PORT:-587}
AIRFLOW__SMTP__SMTP_MAIL_FROM: ${AIRFLOW__SMTP__SMTP_MAIL_FROM:-''}
AIRFLOW__SENTRY__SENTRY_ON: ${AIRFLOW__SENTRY__SENTRY_ON:-false}
AIRFLOW__SENTRY__SENTRY_DSN: ${AIRFLOW__SENTRY__SENTRY_DSN:-''}
# --
AIRFLOW__CORE__EXECUTOR: CeleryExecutor
AIRFLOW__CORE__FERNET_KEY: ${AIRFLOW__CORE__FERNET_KEY:?}
AIRFLOW__CORE__DAGS_FOLDER: /opt/airflow/dags
AIRFLOW__CORE__XCOM_BACKEND: airflow.models.xcom.BaseXCom
AIRFLOW__CORE__AUTH_MANAGER: airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager
AIRFLOW__CORE__LOAD_EXAMPLES: false
AIRFLOW__CORE__DEFAULT_TIMEZONE: America/Sao_Paulo
AIRFLOW__CORE__INTERNAL_API_URL: http://airflow-apiserver:${AIRFLOW_PORT:-8080}
AIRFLOW__CORE__INTERNAL_API_SECRET_KEY: ${AIRFLOW__CORE__INTERNAL_API_SECRET_KEY:?}
AIRFLOW__CORE__EXECUTION_API_SERVER_URL: http://airflow-apiserver:${AIRFLOW_PORT:-8080}/execution
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: ${AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION:-true}
AIRFLOW__CLI__ENDPOINT_URL: http://airflow-apiserver:${AIRFLOW_PORT:-8080}
AIRFLOW__WEBSERVER__BASE_URL: ${AIRFLOW__WEBSERVER__BASE_URL:-https://alertflow.dengue.mat.br}
AIRFLOW__WEBSERVER__SECRET_KEY: ${AIRFLOW__WEBSERVER__SECRET_KEY:?}
AIRFLOW__WEBSERVER__WEB_SERVER_HOST: 0.0.0.0
AIRFLOW__WEBSERVER__WEB_SERVER_PORT: ${AIRFLOW_PORT:-8080}
AIRFLOW__SCHEDULER__ENABLE_HEALTH_CHECK: true
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CELERY__BROKER_URL: redis://:@redis:6379/0
AIRFLOW__API_AUTH__JWT_SECRET: ${AIRFLOW__API_AUTH__JWT_SECRET:?}
AIRFLOW__API_AUTH__JWT_ISSUER: ${AIRFLOW__API_AUTH__JWT_ISSUER:-airflow}
AIRFLOW__API__HOST: 0.0.0.0
AIRFLOW__API__PORT: ${AIRFLOW_PORT:-8080}
AIRFLOW__LOGGING__LOGGING_LEVEL: ${AIRFLOW__LOGGING__LOGGING_LEVEL:-INFO}
volumes:
- ./alertflow/dags:/opt/airflow/dags
- ./alertflow/logs:/opt/airflow/logs
- ./alertflow/plugins:/opt/airflow/plugins
user: "${HOST_UID:-1000}:0"
depends_on: &airflow-common-depends-on
redis:
condition: service_healthy
postgres:
condition: service_healthy
services:
postgres:
image: postgres:16
hostname: postgres
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-airflow}
POSTGRES_DB: airflow
volumes:
- postgres-db-volume:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 10s
retries: 5
start_period: 5s
restart: always
networks:
- alertflow
redis:
image: redis:7.2-bookworm
hostname: redis
expose:
- 6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 30s
retries: 50
start_period: 30s
restart: always
airflow-apiserver:
<<: *airflow-common
command: api-server
hostname: webserver
expose:
- "${AIRFLOW_PORT:-8080}"
healthcheck:
test: ["CMD", "curl", "--fail", "http://airflow-apiserver:${AIRFLOW_PORT:-8080}/api/v2/monitor/health"]
interval: 10s
timeout: 10s
retries: 60
start_period: 60s
restart: always
networks:
- alertflow
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-scheduler:
<<: *airflow-common
command: scheduler
hostname: scheduler
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8974/health"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
restart: always
networks:
- alertflow
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-dag-processor:
<<: *airflow-common
command: dag-processor
hostname: dag-processor
healthcheck:
test: ["CMD-SHELL", 'airflow jobs check --job-type DagProcessorJob --hostname "$${HOSTNAME}"']
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
restart: always
networks:
- alertflow
- infodengue
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-worker:
<<: *airflow-common
command: celery worker
hostname: worker
healthcheck:
# yamllint disable rule:line-length
test: ["CMD-SHELL", 'celery --app airflow.providers.celery.executors.celery_executor.app inspect ping -d "celery@$${HOSTNAME}" || celery --app airflow.executors.celery_executor.app inspect ping -d "celery@$${HOSTNAME}"']
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
environment:
<<: *airflow-common-env
# Required to handle warm shutdown of the celery workers properly
# See https://airflow.apache.org/docs/docker-stack/entrypoint.html#signal-propagation
DUMB_INIT_SETSID: "0"
restart: always
networks:
- alertflow
- infodengue
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-triggerer:
<<: *airflow-common
command: triggerer
hostname: triggerer
healthcheck:
test: ["CMD-SHELL", 'airflow jobs check --job-type TriggererJob --hostname "$${HOSTNAME}"']
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
restart: always
networks:
- alertflow
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-init:
<<: *airflow-common
entrypoint: /bin/bash
restart: "no"
command:
- -c
- |
echo "Airflow version:"
/entrypoint airflow version
mkdir -v -p "${AIRFLOW_HOME}/logs" "${AIRFLOW_HOME}/dags" "${AIRFLOW_HOME}/plugins" "${AIRFLOW_HOME}/config"
chown -R "${HOST_UID}:0" "${AIRFLOW_HOME}"
echo "Initialization done."
environment:
<<: *airflow-common-env
_AIRFLOW_DB_MIGRATE: 'true'
_AIRFLOW_WWW_USER_CREATE: 'true'
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:?}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:?}
_PIP_ADDITIONAL_REQUIREMENTS: ''
user: "0:0"
networks:
- alertflow
airflow-cli:
<<: *airflow-common
profiles:
- debug
environment:
<<: *airflow-common-env
CONNECTION_CHECK_MAX_COUNT: "0"
command:
- bash
- -c
- airflow
depends_on:
<<: *airflow-common-depends-on
networks:
- alertflow
flower:
<<: *airflow-common
command: celery flower
hostname: flower
profiles:
- flower
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:5555/"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
restart: always
networks:
- alertflow
- infodengue
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
volumes:
postgres-db-volume:
networks:
alertflow:
driver: bridge
infodengue:
name: infodengue-${ENV}_infodengue
external: true