{"id":27878975,"url":"https://github.com/sajonaro/airflow-docker","last_synced_at":"2025-05-05T03:16:51.492Z","repository":{"id":270273366,"uuid":"909521809","full_name":"sajonaro/airflow-docker","owner":"sajonaro","description":"a quick airflow + dbt + astronomer-cosmos in docker demo","archived":false,"fork":false,"pushed_at":"2025-01-06T17:41:10.000Z","size":118,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T03:16:46.643Z","etag":null,"topics":["airflow","airflow-dags","airflow-plugin","apache","asatronomer-cosmos","dbt","docker","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sajonaro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-29T00:31:40.000Z","updated_at":"2025-01-06T17:41:13.000Z","dependencies_parsed_at":"2024-12-29T23:28:37.361Z","dependency_job_id":null,"html_url":"https://github.com/sajonaro/airflow-docker","commit_stats":null,"previous_names":["sajonaro/airflow-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajonaro%2Fairflow-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajonaro%2Fairflow-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajonaro%2Fairflow-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sajonaro%2Fairflow-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sajonaro","download_url":"https://codeload.github.com/sajonaro/airflow-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429968,"owners_count":21746574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airflow","airflow-dags","airflow-plugin","apache","asatronomer-cosmos","dbt","docker","python"],"created_at":"2025-05-05T03:16:51.060Z","updated_at":"2025-05-05T03:16:51.480Z","avatar_url":"https://github.com/sajonaro.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## About\n\nThis is a small PoC demonstrating use of airflow + Dbt+ cosmos in docker \n\n\n![diagram](./high-level-diagram.png)\n\n\n\n[Dbt](https://www.getdbt.com/) provides:\n  - well structured transformation pipeline\n      * model first approach: i.e. each transformation step is defined as 'model'\n  - testing\n  - version control\n  - modularization \u0026 centralization of (analytics) code\n\n  \n[Cosmos](https://www.astronomer.io/cosmos/) provides:\n  - automatic conversion of Dbt projects into DAGs\n  - dependency visualization\n  - ability to run any number of Dbt jobs (virtually for free as there is dependency on Dbt core only)\n\n[Airflow](https://airflow.apache.org/) provides:\n  - extensible automation/orchestrating platform to run Dbt steps as [DAGs](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html#dags)\n  - web ui\n  - cli \n  - ..and more\n\n## 101\n* start up the stack\n  ```bash\n  $ ./start.sh\n  ```\n  ... which does following  \n    ```bash\n    $ docker compose up airflow-init  \n    $ sleep 5\n    $ docker compose up   \n    ```\n* configure 'connections' (so that Dbt can use them) via Airflow UI\n   - open http://localhost:8080   (u,p -\u003e airflow,airflow   - check docker-compose.yml ) \n   - navigate to Admin/Connections/ add new \n   - e.g we need to create `ex1_db` and `ex2_db` (see ./dags/include.profiles.py  to see why)\n   - connection details are postgresql://airflow:airflow@northwind:5454/ex1 ( check docker-compose.yml)\n\n* to use dbt cli (via docker compose):\n  ```bash\n  # use dbt commands [e.g init, run, seed, test ]\n  # and then follow command prompts \n  $ docker compose run --rm dbt-cli dbt init\n  ```  \n  .. or alternatively (via virtual environment)\n  ```bash\n  # 1 - create virtual environment = dbt  \n  # 2 - activate it \n  # 3 - install dbt libs\n\n  $ python3 -m venv dbt \\\n    \u0026\u0026 source dbt/bin/activate \\\n    \u0026\u0026 pip install dbt-core dbt-postgres \\\n    \u0026\u0026 deactivate\n  ```\n   \n\n\n### some useful commands\n* use postgres cli\n  ```bash\n    # attach to db container as root\n    # then connect to database e.g. \n    #     user = airflow,  db = ex1, port = 5454\n    $ psql -U airflow -h localhost ex1 -p 5454\n\n    # 'out' is the schema name\n    SELECT * FROM pg_catalog.pg_tables WHERE schemaname='out';\n\n    # assuming there is table `customers` in schema `out`\n    SELECT * from out.customers;\n  ```\n\n* if on linux \n\n  ```bash\n    #create directories\n    $ mkdir ./dags ./logs ./plugins ./dbt\n    #configure UID and GID\n    $ echo -e \"AIRFLOW_UID=$(id -u)\\nAIRFLOW_GID=0\" \u003e .env\n  ``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajonaro%2Fairflow-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsajonaro%2Fairflow-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsajonaro%2Fairflow-docker/lists"}