-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
116 lines (111 loc) · 3.65 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
services:
postgres:
image: postgres:17
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- ./postgres/initdb:/docker-entrypoint-initdb.d/
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 1s
retries: 10
postgres_airflow:
image: postgres:17
environment:
POSTGRES_USER: ${AIRFLOW_POSTGRES_USER}
POSTGRES_PASSWORD: ${AIRFLOW_POSTGRES_PASSWORD}
POSTGRES_DB: ${AIRFLOW_POSTGRES_DB}
ports:
- "5433:5432"
volumes:
- postgres_airflow_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${AIRFLOW_POSTGRES_USER} -d ${AIRFLOW_POSTGRES_DB}"]
interval: 1s
retries: 10
fastapi:
build:
context: .
dockerfile: ./fastapi/Dockerfile
env_file:
- .env
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_HOST: postgres
SQLALCHEMY_DATABASE_URL: postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres/${POSTGRES_DB}
depends_on:
postgres:
condition: service_healthy
ports:
- "8000:8000"
airflow-scheduler:
build:
context: .
dockerfile: ./airflow/Dockerfile
depends_on:
postgres_airflow:
condition: service_healthy
env_file:
- .env
environment:
PYTHONPATH: /opt/airflow
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://${AIRFLOW_POSTGRES_USER}:${AIRFLOW_POSTGRES_PASSWORD}@postgres_airflow/${AIRFLOW_POSTGRES_DB}
AIRFLOW__CORE__FERNET_KEY: '${AIRFLOW_FERNET_KEY}'
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW__WEBSERVER__WORKERS: 4
volumes:
- ./airflow/dags:/opt/airflow/dags
- ./airflow/utils:/opt/airflow/utils
- airflow_logs:/opt/airflow/logs
- airflow_plugins:/opt/airflow/plugins
entrypoint: >
bash -c "
airflow db init &&
airflow scheduler"
airflow-webserver:
build:
context: .
dockerfile: ./airflow/Dockerfile
depends_on:
postgres_airflow:
condition: service_healthy
env_file:
- .env
environment:
PYTHONPATH: /opt/airflow
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://${AIRFLOW_POSTGRES_USER}:${AIRFLOW_POSTGRES_PASSWORD}@postgres_airflow/${AIRFLOW_POSTGRES_DB}
AIRFLOW__CORE__FERNET_KEY: '${AIRFLOW_FERNET_KEY}'
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW_WEB_USERNAME: ${AIRFLOW_WEB_USERNAME}
AIRFLOW_WEB_PASSWORD: ${AIRFLOW_WEB_PASSWORD}
AIRFLOW_WEB_FIRST_NAME: ${AIRFLOW_WEB_FIRST_NAME}
AIRFLOW_WEB_LAST_NAME: ${AIRFLOW_WEB_LAST_NAME}
AIRFLOW_WEB_ROLE: ${AIRFLOW_WEB_ROLE}
AIRFLOW_WEB_EMAIL: ${AIRFLOW_WEB_EMAIL}
ports:
- "8080:8080"
volumes:
- ./airflow/dags:/opt/airflow/dags
- ./airflow/utils:/opt/airflow/utils
- airflow_logs:/opt/airflow/logs
- airflow_plugins:/opt/airflow/plugins
entrypoint: >
bash -c "
sleep 5 &&
airflow db init &&
airflow users create --username ${AIRFLOW_WEB_USERNAME} --password ${AIRFLOW_WEB_PASSWORD} --firstname ${AIRFLOW_WEB_FIRST_NAME} --lastname ${AIRFLOW_WEB_LAST_NAME} --role ${AIRFLOW_WEB_ROLE} --email ${AIRFLOW_WEB_EMAIL} &&
airflow webserver"
volumes:
airflow_logs:
airflow_plugins:
postgres_data:
postgres_airflow_data: