Skip to content

Commit 7bbdafa

Browse files
committed
first commit
0 parents  commit 7bbdafa

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docker-volumes
2+
*.pyc

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Data Stack
2+
3+
A sample data stack running on Docker, that contains the following services:
4+
5+
- [Airflow](https://airflow.apache.org/) (with its Postgres database)
6+
- [Metabase](https://metabase.com/) (with its Postgres database)
7+
- [MariaDB](https://mariadb.org/) (as main database)
8+
9+
Run it with:
10+
11+
``` text
12+
docker-compose up -d
13+
```
14+
15+
Then visit:
16+
17+
- [localhost:3000](http://localhost:3000): for Metabase
18+
- [localhost:8080](http://localhost:8080): for Airflow
19+
20+
Add your Airflow DAGS in the [airflow-dags](./airflow-dags) folder.
21+
22+
Credits to:
23+
24+
- [puckel/docker-airflow](https://github.com/puckel/docker-airflow)

airflow-dags/example.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""
2+
Code that goes along with the Airflow located at:
3+
http://airflow.readthedocs.org/en/latest/tutorial.html
4+
"""
5+
from airflow import DAG
6+
from airflow.operators.bash_operator import BashOperator
7+
from datetime import datetime, timedelta
8+
9+
10+
default_args = {
11+
"owner": "airflow",
12+
"depends_on_past": False,
13+
"start_date": datetime(2015, 6, 1),
14+
"email": ["airflow@airflow.com"],
15+
"email_on_failure": False,
16+
"email_on_retry": False,
17+
"retries": 1,
18+
"retry_delay": timedelta(minutes=5),
19+
# 'queue': 'bash_queue',
20+
# 'pool': 'backfill',
21+
# 'priority_weight': 10,
22+
# 'end_date': datetime(2016, 1, 1),
23+
}
24+
25+
dag = DAG("tutorial", default_args=default_args, schedule_interval=timedelta(1))
26+
27+
# t1, t2 and t3 are examples of tasks created by instantiating operators
28+
t1 = BashOperator(task_id="print_date", bash_command="date", dag=dag)
29+
30+
t2 = BashOperator(task_id="sleep", bash_command="sleep 5", retries=3, dag=dag)
31+
32+
templated_command = """
33+
{% for i in range(5) %}
34+
echo "{{ ds }}"
35+
echo "{{ macros.ds_add(ds, 7)}}"
36+
echo "{{ params.my_param }}"
37+
{% endfor %}
38+
"""
39+
40+
t3 = BashOperator(
41+
task_id="templated",
42+
bash_command=templated_command,
43+
params={"my_param": "Parameter I passed in"},
44+
dag=dag,
45+
)
46+
47+
t2.set_upstream(t1)
48+
t3.set_upstream(t1)

docker-compose.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: "3"
2+
3+
services:
4+
mariadb:
5+
image: mariadb
6+
environment:
7+
MYSQL_ROOT_PASSWORD: password
8+
MYSQL_USER: user
9+
MYSQL_PASSWORD: password
10+
ports:
11+
- 3306:3306
12+
volumes:
13+
- ./docker-volumes/mariadb:/var/lib/mysql
14+
15+
metabase:
16+
image: metabase/metabase
17+
ports:
18+
- 3000:3000
19+
depends_on:
20+
- metabase-postgres
21+
environment:
22+
MB_DB_TYPE: postgres
23+
MB_DB_DBNAME: metabase
24+
MB_DB_PORT: 5432
25+
MB_DB_USER: user
26+
MB_DB_PASS: password
27+
MB_DB_HOST: metabase-postgres
28+
29+
metabase-postgres:
30+
image: postgres
31+
environment:
32+
POSTGRES_PASSWORD: password
33+
POSTGRES_USER: user
34+
POSTGRES_DB: metabase
35+
volumes:
36+
- ./docker-volumes/metabase-postgres:/var/lib/postgresql/data/
37+
38+
airflow-webserver:
39+
image: puckel/docker-airflow:1.10.2
40+
restart: always
41+
depends_on:
42+
- airflow-postgres
43+
environment:
44+
- LOAD_EX=n
45+
- EXECUTOR=Local
46+
- POSTGRES_HOST=airflow-postgres
47+
volumes:
48+
- ./airflow-dags:/usr/local/airflow/dags
49+
# Uncomment to include custom plugins
50+
# - ./airflow-plugins:/usr/local/airflow/plugins
51+
ports:
52+
- "8080:8080"
53+
command: webserver
54+
healthcheck:
55+
test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
56+
interval: 30s
57+
timeout: 30s
58+
retries: 3
59+
60+
airflow-postgres:
61+
image: postgres:9.6
62+
environment:
63+
- POSTGRES_USER=airflow
64+
- POSTGRES_PASSWORD=airflow
65+
- POSTGRES_DB=airflow
66+
volumes:
67+
- ./docker-volumes/airflow-postgres:/var/lib/postgresql/data/

0 commit comments

Comments
 (0)