105 lines
2.7 KiB
YAML
105 lines
2.7 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# PostgreSQL for Airflow metadata
|
|
postgres-metadata:
|
|
image: postgres:16
|
|
environment:
|
|
POSTGRES_USER: airflow
|
|
POSTGRES_PASSWORD: airflow
|
|
POSTGRES_DB: airflow
|
|
ports:
|
|
- "5434:5432"
|
|
volumes:
|
|
- pgmeta:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U airflow -d airflow"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
|
|
# PostgreSQL for training exercises
|
|
postgres-training:
|
|
image: postgres:16
|
|
environment:
|
|
POSTGRES_USER: student
|
|
POSTGRES_PASSWORD: student
|
|
POSTGRES_DB: training
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- pg_data:/var/lib/postgresql/data
|
|
- ./init-postgres.sql:/docker-entrypoint-initdb.d/init-postgres.sql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U student -d training"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
|
|
# Airflow webserver
|
|
airflow-webserver:
|
|
build: .
|
|
image: airflow-optimized:2.9.2
|
|
environment:
|
|
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
|
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
|
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
|
command: >
|
|
bash -c "
|
|
airflow webserver
|
|
"
|
|
ports:
|
|
- "8080:8080"
|
|
volumes:
|
|
- ./dags:/opt/airflow/dags
|
|
- ./data:/opt/airflow/data
|
|
depends_on:
|
|
postgres-metadata:
|
|
condition: service_healthy
|
|
postgres-training:
|
|
condition: service_healthy
|
|
|
|
# Airflow scheduler
|
|
airflow-scheduler:
|
|
build: .
|
|
# image: airflow-optimized:2.9.2
|
|
environment:
|
|
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
|
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
|
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
|
command: >
|
|
bash -c "
|
|
airflow scheduler
|
|
"
|
|
volumes:
|
|
- ./dags:/opt/airflow/dags
|
|
- ./data:/opt/airflow/data
|
|
depends_on:
|
|
postgres-metadata:
|
|
condition: service_healthy
|
|
postgres-training:
|
|
condition: service_healthy
|
|
|
|
# Airflow init to create admin user
|
|
airflow-init:
|
|
build: .
|
|
# image: airflow-optimized:2.9.2
|
|
environment:
|
|
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
|
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
|
volumes:
|
|
- ./dags:/opt/airflow/dags
|
|
- ./data:/opt/airflow/data
|
|
command: >
|
|
bash -c "
|
|
airflow db migrate &&
|
|
airflow users create --username admin --password admin --firstname Admin --lastname User --role Admin --email admin@example.org
|
|
"
|
|
depends_on:
|
|
postgres-metadata:
|
|
condition: service_healthy
|
|
|
|
volumes:
|
|
pgmeta:
|
|
pg_data:
|