Первоначальная реализация
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
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:
|
||||
image: apache/airflow:2.9.2
|
||||
environment:
|
||||
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
||||
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
||||
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
||||
command: >
|
||||
bash -c "
|
||||
pip install --no-cache-dir psycopg2-binary &&
|
||||
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:
|
||||
image: apache/airflow:2.9.2
|
||||
environment:
|
||||
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
||||
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
||||
AIRFLOW__CORE__EXECUTOR: LocalExecutor
|
||||
command: >
|
||||
bash -c "
|
||||
pip install --no-cache-dir psycopg2-binary &&
|
||||
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:
|
||||
image: apache/airflow:2.9.2
|
||||
environment:
|
||||
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
|
||||
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
|
||||
volumes:
|
||||
- ./dags:/opt/airflow/dags
|
||||
- ./data:/opt/airflow/data
|
||||
command: >
|
||||
bash -c "
|
||||
pip install --no-cache-dir psycopg2-binary &&
|
||||
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:
|
||||
Reference in New Issue
Block a user