-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
59 lines (56 loc) · 2.12 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
version: '3'
services:
postgres-books-db:
image: postgres:13
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data # Persistent volume for data
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
webserver:
image: apache/airflow:2.5.0
depends_on:
- postgres-books-db
environment:
- AIRFLOW__CORE__EXECUTOR=LocalExecutor
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres-books-db:5432/${POSTGRES_DB}
- AIRFLOW__WEBSERVER__SECRET_KEY=${AIRFLOW__WEBSERVER__SECRET_KEY}
- AIRFLOW__CORE__DEFAULT_TIMEZONE=America/New_York
- SLACK_API_TOKEN=${SLACK_API_TOKEN}
- GOOGLE_BOOKS_API_KEY=${GOOGLE_BOOKS_API_KEY}
- TZ=America/New_York
command: >
bash -c "airflow db init &&
airflow users create --username ${AIRFLOW_ADMIN_USERNAME} --password ${AIRFLOW_ADMIN_PASSWORD} --firstname Admin --lastname Admin --role Admin --email admin@example.com &&
airflow webserver"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
ports:
- "8080:8080"
scheduler:
image: apache/airflow:2.5.0
environment:
- AIRFLOW__CORE__EXECUTOR=LocalExecutor
- AIRFLOW__CORE__SQL_ALCHEMY_CONN=postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres-books-db:5432/${POSTGRES_DB}
- AIRFLOW__WEBSERVER__SECRET_KEY=${AIRFLOW__WEBSERVER__SECRET_KEY}
- AIRFLOW__CORE__DEFAULT_TIMEZONE=America/New_York
- SLACK_API_TOKEN=${SLACK_API_TOKEN}
- GOOGLE_BOOKS_API_KEY=${GOOGLE_BOOKS_API_KEY}
command: >
bash -c "airflow db init && airflow scheduler"
depends_on:
- webserver
volumes:
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
volumes:
postgres_data: # Define the named volume