-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose.yml
197 lines (186 loc) · 6.18 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
version: '3'
x-airflow-common:
&airflow-common
image: apache/airflow:2.6.2
# user: "${AIRFLOW_UID}:${AIRFLOW_GID}"
user: "50000:0"
env_file:
- ./airflow.properties
environment:
GOOGLE_APPLICATION_CREDENTIALS: /gcp/gcloud/application_default_credentials.json
GOOGLE_CLOUD_PROJECT: ${GOOGLE_CLOUD_PROJECT}
CLOUDSDK_CORE_PROJECT: ${GOOGLE_CLOUD_PROJECT}
GCP_REGION: ${GCP_REGION}
AWS_CREDENTIALS_PATH: /opt/airflow/credentials/${AWS_CREDENTIALS_FILENAME}
entrypoint: ./airflow-entrypoint.sh
volumes:
- ./src/dags:/opt/airflow/dags
- ./src/logs:/opt/airflow/logs
- ./src/plugins:/opt/airflow/plugins
- ./src/config:/opt/airflow/config
# airflow-GCP ADC
- ${APPDATA}/gcloud:/gcp/gcloud
- ./airflow-entrypoint.sh:/opt/airflow/airflow-entrypoint.sh
# airflow-kaggle auth
- ./credentials/kaggle.json:/home/airflow/.kaggle/kaggle.json
# airflow-AWS
- ./credentials:/opt/airflow/credentials
# for docker operator requied docker sesseion on local
- //var/run/docker.sock:/var/run/docker.sock
x-depends-on:
&depends-on
depends_on:
airflow-postgres:
condition: service_healthy
airflow-init:
condition: service_completed_successfully
services:
postgres-source:
build:
context: .
dockerfile: postgres.Dockerfile
image: postgres-source
container_name: postgres-container-source
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mydatabase
ports:
- 5432:5432
restart: unless-stopped
# volumes:
# - ./src/pgdata_source:/var/lib/postgresql/data
postgres-target:
build:
context: .
dockerfile: postgres-target.Dockerfile
image: postgres-target
container_name: postgres-container-target
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: targetdb
ports:
- 5433:5432
restart: unless-stopped
# volumes:
# - ./src/pgdata_target:/var/lib/postgresql/data
airflow-postgres:
image: postgres:13
container_name: airflow-postgres
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 10s
retries: 5
start_period: 5s
volumes:
- ./src/postgres-db-volume:/var/lib/postgresql/data
restart: always
airflow-scheduler:
<<: *airflow-common
build:
context: .
dockerfile: airflow.Dockerfile
container_name: airflow-scheduler
command: scheduler
restart: always
airflow-webserver:
<<: *airflow-common
build:
context: .
dockerfile: airflow.Dockerfile
container_name: airflow-webserver
command: webserver
ports:
- "8080:8080"
restart: always
airflow-init:
<<: *airflow-common
container_name: airflow-init
entrypoint: /bin/bash
# yamllint disable rule:line-length
# user: "${AIRFLOW_UID}:${AIRFLOW_GID}"
user: "0:0"
command:
- -c
- |
function ver() {
printf "%04d%04d%04d%04d" $${1//./ }
}
if [[ -z "${AIRFLOW_UID}" ]]; then
echo
echo -e "\033[1;33mWARNING!!!: AIRFLOW_UID not set!\e[0m"
echo "If you are on Linux, you SHOULD follow the instructions below to set "
echo "AIRFLOW_UID and AIRFLOW_GID environment variables, otherwise files will be owned by root."
echo "For other operating systems you can get rid of the warning with manually created .env file:"
echo " See: https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#setting-the-right-airflow-user"
echo
fi
one_meg=1048576
mem_available=$$(($$(getconf _PHYS_PAGES) * $$(getconf PAGE_SIZE) / one_meg))
cpus_available=$$(grep -cE 'cpu[0-9]+' /proc/stat)
disk_available=$$(df / | tail -1 | awk '{print $$4}')
warning_resources="false"
if (( mem_available < 4000 )) ; then
echo
echo -e "\033[1;33mWARNING!!!: Not enough memory available for Docker.\e[0m"
echo "At least 4GB of memory required. You have $$(numfmt --to iec $$((mem_available * one_meg)))"
echo
warning_resources="true"
fi
if (( cpus_available < 2 )); then
echo
echo -e "\033[1;33mWARNING!!!: Not enough CPUS available for Docker.\e[0m"
echo "At least 2 CPUs recommended. You have $${cpus_available}"
echo
warning_resources="true"
fi
if (( disk_available < one_meg * 10 )); then
echo
echo -e "\033[1;33mWARNING!!!: Not enough Disk space available for Docker.\e[0m"
echo "At least 10 GBs recommended. You have $$(numfmt --to iec $$((disk_available * 1024 )))"
echo
warning_resources="true"
fi
if [[ $${warning_resources} == "true" ]]; then
echo
echo -e "\033[1;33mWARNING!!!: You have not enough resources to run Airflow (see above)!\e[0m"
echo "Please follow the instructions to increase amount of resources available:"
echo " https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#before-you-begin"
echo
fi
mkdir -p /sources/logs /sources/dags /sources/plugins
chown -R "${AIRFLOW_UID}:${AIRFLOW_GID}" /sources/{logs,dags,plugins}
exec /entrypoint airflow version
# mailhog:
# image: mailhog/mailhog
# container_name: mailhog-container
# ports:
# - 1025:1025
# - 8025:8025
# minio-s3:
# image: minio/minio:RELEASE.2022-01-08T03-11-54Z
# container_name: minio-container
# environment:
# MINIO_ROOT_USER: minio
# MINIO_ROOT_PASSWORD: minio123
# ports:
# - 9000:9000
# - 9001:9001
# volumes:
# - ./src/minio-data-volume:/data
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
# interval: 30s
# timeout: 20s
# retries: 3
# restart: always
# command: server /data --console-address ":9001"
volumes:
# pgdata_source:
# pgdata_target:
postgres-db-volume: