konosp / dbt-airflow-docker-compose

Execution of DBT models using Apache Airflow through Docker Compose
https://analyticsmayhem.com/dbt/apache-airflow-dbt-docker-compose/
Apache License 2.0
113 stars 52 forks source link
airflow dbt docker docker-compose

Apache Airflow and DBT using Docker Compose

Stand-alone project that utilises public eCommerce data from Instacart to demonstrate how to schedule dbt models through Airflow.

For more Data & Analytics related reading, check https://analyticsmayhem.com

Requirements

Setup

Change directory within the repository and run docker-compose up. This will perform the following:

Connections

How to ran the DAGs

Once everything is up and running, navigate to the Airflow UI (see connections above). You will be presented with the list of DAGs, all Off by default.

You will need to run to execute them in correct order.

If everything goes well, you should have the daily model execute successfully and see similar task durations as per below.

Finally, within Adminer you can view the final models.

Docker Compose Commands

If you need to connect to the running containers, use docker-compose ps to view the running services.

For example, to connect to the Airflow service, you can execute docker exec -it dbt-airflow-docker_airflow_1 /bin/bash. This will attach your terminal to the selected container and activate a bash terminal.

Project Notes and Docker Volumes

Because the project directories (./scripts_postgres, ./sample_data, ./dbt and ./airflow) are defined as volumes in docker-compose.yml, they are directly accessible from within the containers. This means:

Credit to the very helpful repository: https://github.com/puckel/docker-airflow

Infrastructure model

Infrastructure model