forked from hankehly/deploy-airflow-on-ecs-fargate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
168 lines (158 loc) · 4.75 KB
/
docker-compose.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
---
x-airflow-common:
&airflow-common
build:
context: .
dockerfile: ./build/dev/Containerfile
environment:
&airflow-common-env
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@airflow-db/airflow
# THIS IS A FAKE CREDENTIAL FOR DEMONSTRATION PURPOSES
# Generate with the following code
# python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key())'
AIRFLOW__CORE__FERNET_KEY: "Ly8wMU8r5K7jPy58M3GpkZbXDNyJz8HiJll3pu8DbIM="
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@airflow-db/airflow
AIRFLOW__CELERY__BROKER_URL: sqs://user:pass@celery-broker:9324/
AIRFLOW__WEBSERVER__INSTANCE_NAME: "${AIRFLOW__WEBSERVER__INSTANCE_NAME:-deploy-airflow-on-ecs-fargate}"
AIRFLOW__LOGGING__LOGGING_LEVEL: DEBUG
PYTHONPATH: "/opt/airflow/deploy_airflow_on_ecs_fargate:$PYTHONPATH"
# Gotcha: Even though we set this to "True" in airflow.cfg, an environment variable overrides it
AIRFLOW__CORE__LOAD_EXAMPLES: True
volumes:
- ./dags:/opt/airflow/dags
- ./plugins:/opt/airflow/plugins
- ./build/dev/airflow.cfg:/opt/airflow/airflow.cfg
- ./deploy_airflow_on_ecs_fargate:/opt/airflow/deploy_airflow_on_ecs_fargate
- ./scripts:/opt/airflow/scripts
user: "50000:0"
depends_on:
&airflow-common-depends-on
celery-broker:
condition: service_started
airflow-db:
condition: service_healthy
services:
airflow-db:
image: postgres:13
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- airflow-db-volume:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready", "-U", "airflow" ]
interval: 5s
retries: 5
restart: always
# For environment parity, use backend that implements SQS interface
# https://github.com/roribio/alpine-sqs
celery-broker:
image: roribio16/alpine-sqs:latest
expose:
- 9324
- 9325
restart: always
airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- 8080:8080
healthcheck:
test:
[
"CMD",
"curl",
"--fail",
"http://localhost:8080/health"
]
interval: 35s
timeout: 30s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-scheduler:
<<: *airflow-common
command: scheduler
healthcheck:
test:
[
"CMD-SHELL",
'airflow jobs check --job-type SchedulerJob --hostname "$${HOSTNAME}"'
]
interval: 35s
timeout: 30s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-worker:
<<: *airflow-common
command: celery worker
# SQS does not support worker remote control commands.
# This means we can't use the 'ping' command as a healthcheck.
# healthcheck:
# test:
# - "CMD-SHELL"
# - 'celery --app airflow.executors.celery_executor.app inspect ping -d "celery@$${HOSTNAME}"'
# interval: 35s
# timeout: 30s
# retries: 5
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
depends_on:
<<: *airflow-common-depends-on
# AIP-40: Deferrable ("Async") Operators
# https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=177050929
airflow-triggerer:
<<: *airflow-common
command: triggerer
healthcheck:
test:
[
"CMD-SHELL",
'airflow jobs check --job-type TriggererJob --hostname "$${HOSTNAME}"'
]
interval: 35s
timeout: 30s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-cli:
<<: *airflow-common
profiles:
- debug
environment:
<<: *airflow-common-env
CONNECTION_CHECK_MAX_COUNT: "0"
# Workaround for entrypoint issue. See: https://github.com/apache/airflow/issues/16252
command:
- bash
- -c
- airflow
# A service to translate statsd input into prometheus compatible metrics
# https://hub.docker.com/r/prom/statsd-exporter
statsd-exporter:
image: prom/statsd-exporter
command: "--statsd.listen-udp=:8125 --web.listen-address=:9102"
ports:
# You can open localhost:9102/metrics to see what is being exported
- 9102:9102
restart: always
prometheus:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- ./build/dev/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-volume:/prometheus
restart: always
volumes:
airflow-db-volume:
prometheus-volume: