-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
142 lines (132 loc) · 3.43 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
version: "3.9"
name: analytics-engineer-assignment
x-airflow-common:
&airflow-common
image: airflow-clara-local:latest
build:
dockerfile: ./Dockerfile.airflow
context: .
env_file:
- ./.env.airflow.local
- ./.env.dbt.local
environment:
- DBT_POSTGRES_HOST=postgres
- DBT_POSTGRES_PORT=5432
volumes:
- ./dags:/opt/airflow/dags
- ./dbt:/opt/airflow/dbt:rw
x-airflow-depends-on:
&airflow-depends-on
depends_on:
airflow-db-metadata:
condition: service_healthy
airflow-init:
condition: service_completed_successfully
services:
postgres:
container_name: postgres
hostname: postgres
image: postgres:${POSTGRES_VERSION:-14.7}
env_file:
- ./.env.postgres.local
ports:
- ${POSTGRES_EXT_PORT:-5440}:${POSTGRES_PORT:-5432}
restart: unless-stopped
volumes:
- ./scripts/postgres_init.sh:/docker-entrypoint-initdb.d/postgres_init.sh
- postgres-volume:/var/lib/postgresql/data
healthcheck:
test:
[
"CMD",
"pg_isready",
"-U",
"${POSTGRES_USER}",
"-d",
"${POSTGRES_DB}"
]
interval: 10s
timeout: 5s
retries: 5
bootstrap-dbt:
image: bootstrap-dbt:latest
build:
dockerfile: ./Dockerfile.dbt
context: .
container_name: bootstrap-dbt
depends_on:
postgres:
condition: service_healthy
working_dir: /code
entrypoint:
- /bin/bash
- -c
- poetry run dbt seed --target prod --project-dir dbt --profiles-dir dbt
restart: "no"
env_file:
- .env.dbt.local
environment:
- DBT_POSTGRES_HOST=postgres
- DBT_POSTGRES_PORT=5432
airflow-db-metadata:
image: postgres:${AIRFLOW_POSTGRES_VERSION:-14.7}
container_name: airflow-db-metadata
hostname: airflow-db-metadata
env_file:
- ./.env.airflow.local
environment:
- POSTGRES_USER=${AIRFLOW_POSTGRES_USER}
- POSTGRES_PASSWORD=${AIRFLOW_POSTGRES_PASSWORD}
- POSTGRES_DB=${AIRFLOW_POSTGRES_DB}
- POSTGRES_PORT=${AIRFLOW_POSTGRES_PORT}
volumes:
- airflow-db-metadata-volume:/var/lib/postgresql/data
ports:
- ${AIRFLOW_POSTGRES_PORT_HOST:-5441}:${AIRFLOW_POSTGRES_PORT:-5432}
restart: on-failure
healthcheck:
test: [ "CMD", "pg_isready", "-U", "${AIRFLOW_POSTGRES_USER:-airflow}" ]
interval: 5s
retries: 5
airflow-scheduler:
<<: [*airflow-common, *airflow-depends-on]
container_name: airflow-scheduler
command: scheduler
restart: on-failure
ports:
- 8793:8793
airflow-webserver:
<<: [*airflow-common, *airflow-depends-on]
container_name: airflow-webserver
restart: on-failure
command: webserver
ports:
- ${AIRFLOW_WEBSERVER_PORT_HOST:-8080}:8080
healthcheck:
test:
[
"CMD",
"curl",
"--fail",
"http://localhost:${AIRFLOW_WEBSERVER_PORT_HOST:-8080}/health"
]
interval: 30s
timeout: 30s
retries: 5
airflow-init:
<<: *airflow-common
container_name: airflow-init
entrypoint: /bin/bash
user: 0:0
command:
- -c
- |
mkdir -p /sources/logs /sources/dags /sources/plugins
chown -R "${AIRFLOW_UID:-0}:0" /sources/{logs,dags,plugins}
exec /entrypoint airflow db init
volumes:
airflow-db-metadata-volume:
postgres-volume:
networks:
default:
name: analytics-engineer-assignment