|
1 | 1 | name: carrot-mapper-dev |
2 | 2 |
|
| 3 | +x-airflow-common: |
| 4 | + &airflow-common |
| 5 | + profiles: ["main"] |
| 6 | + volumes: |
| 7 | + - ./app/airflow/dags:/opt/airflow/dags |
| 8 | + depends_on: |
| 9 | + db: |
| 10 | + condition: service_started |
| 11 | + minio: |
| 12 | + condition: service_started |
| 13 | + api: |
| 14 | + condition: service_healthy |
| 15 | + environment: |
| 16 | + &airflow-common-env |
| 17 | + AIRFLOW__CORE__EXECUTOR: LocalExecutor |
| 18 | + # Database connection here needs to be in URI format. With real values, which have special characters, they need to be encoded using the ref. in https://www.w3schools.com/tags/ref_urlencode.ASP. |
| 19 | + AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres?options=-csearch_path%3Dairflow |
| 20 | + AIRFLOW__DATABASE__SQL_ALCHEMY_SCHEMA: airflow |
| 21 | + AIRFLOW__CORE__LOAD_EXAMPLES: "false" |
| 22 | + AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "False" |
| 23 | + AIRFLOW__WEBSERVER__WEB_SERVER_PORT: 8080 |
| 24 | + AIRFLOW__API__AUTH_BACKEND: airflow.api.auth.backend.basic_auth |
| 25 | + # This connection can be in separate variables (then don't need to do URL encoding), but it can reuse the same connection string with SQL_ALCHEMY_CONN (without extras) |
| 26 | + AIRFLOW_CONN_POSTGRES_DB_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres |
| 27 | + # The blob storage where Airflow get/put necessary files |
| 28 | + STORAGE_TYPE: minio |
| 29 | + # Minio connection variables (don't need to do URL encoding here) |
| 30 | + AIRFLOW_VAR_MINIO_ENDPOINT: http://minio:9000 |
| 31 | + AIRFLOW_VAR_MINIO_ACCESS_KEY: minioadmin |
| 32 | + AIRFLOW_VAR_MINIO_SECRET_KEY: minioadmin |
| 33 | + # WASB connection string (don't need to do URL encoding here) |
| 34 | + AIRFLOW_VAR_WASB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1 |
| 35 | + |
3 | 36 | services: |
4 | 37 | db: |
5 | 38 | image: postgres:14 |
@@ -51,6 +84,8 @@ services: |
51 | 84 | depends_on: |
52 | 85 | api: |
53 | 86 | condition: service_healthy |
| 87 | + airflow-webserver: |
| 88 | + condition: service_healthy |
54 | 89 |
|
55 | 90 | api: |
56 | 91 | image: carrot-backend |
@@ -189,70 +224,37 @@ services: |
189 | 224 | retries: 5 |
190 | 225 |
|
191 | 226 | airflow-webserver: |
192 | | - profiles: ["main"] |
| 227 | + <<: *airflow-common |
193 | 228 | build: |
194 | 229 | context: app/airflow |
195 | | - dockerfile: Dockerfile.webserver |
196 | | - depends_on: |
197 | | - db: |
198 | | - condition: service_started |
199 | | - api: |
200 | | - condition: service_healthy |
| 230 | + dockerfile: Dockerfile |
| 231 | + args: |
| 232 | + AIRFLOW_COMPONENT: webserver |
| 233 | + ports: |
| 234 | + - "8080:8080" |
| 235 | + healthcheck: |
| 236 | + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] |
| 237 | + interval: 10s |
| 238 | + timeout: 5s |
| 239 | + retries: 5 |
201 | 240 | environment: |
202 | | - AIRFLOW__CORE__EXECUTOR: LocalExecutor |
203 | | - # Database connection here needs to be in URI format. With real values, which have special characters, they need to be encoded using the ref. in https://www.w3schools.com/tags/ref_urlencode.ASP. |
204 | | - AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres?options=-csearch_path%3Dairflow |
205 | | - AIRFLOW__DATABASE__SQL_ALCHEMY_SCHEMA: airflow |
206 | | - AIRFLOW__CORE__LOAD_EXAMPLES: "false" |
207 | | - AIRFLOW__WEBSERVER__WEB_SERVER_PORT: 8080 |
208 | | - AIRFLOW__WEBSERVER__SECRET_KEY: "test" |
209 | | - AIRFLOW__API__AUTH_BACKENDS: airflow.api.auth.backend.basic_auth |
210 | | - AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "False" |
211 | | - # This connection can be in separate variables (then don't need to do URL encoding), but it can reuse the same connection string with SQL_ALCHEMY_CONN (without extras) |
212 | | - AIRFLOW_CONN_POSTGRES_DB_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres |
213 | | - # The blob storage where Airflow get/put necessary files |
214 | | - STORAGE_TYPE: minio |
215 | | - # Minio connection variables (don't need to do URL encoding here) |
216 | | - AIRFLOW_VAR_MINIO_ENDPOINT: http://minio:9000 |
217 | | - AIRFLOW_VAR_MINIO_ACCESS_KEY: minioadmin |
218 | | - AIRFLOW_VAR_MINIO_SECRET_KEY: minioadmin |
219 | | - # WASB connection string (don't need to do URL encoding here) |
220 | | - AIRFLOW_VAR_WASB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1 |
| 241 | + <<: *airflow-common-env |
221 | 242 | # Admin user configuration to access the Airlfow API |
| 243 | + # TODO: add optional admin user configuration in the docs |
222 | 244 | AIRFLOW_ADMIN_USERNAME: admin |
223 | 245 | AIRFLOW_ADMIN_PASSWORD: admin |
224 | | - # TODO: add optional admin user configuration in the docs |
225 | | - volumes: |
226 | | - - ./app/airflow/dags:/opt/airflow/dags |
227 | | - ports: |
228 | | - - "8080:8080" |
229 | | - |
| 246 | + |
230 | 247 | scheduler: |
231 | | - profiles: ["main"] |
| 248 | + <<: *airflow-common |
232 | 249 | build: |
233 | 250 | context: app/airflow |
234 | | - dockerfile: Dockerfile.scheduler |
235 | | - depends_on: |
236 | | - api: |
237 | | - condition: service_healthy |
238 | | - airflow-webserver: |
239 | | - condition: service_started |
| 251 | + dockerfile: Dockerfile |
| 252 | + args: |
| 253 | + AIRFLOW_COMPONENT: scheduler |
240 | 254 | environment: |
241 | | - AIRFLOW__CORE__EXECUTOR: LocalExecutor |
| 255 | + <<: *airflow-common-env |
242 | 256 | AIRFLOW__CORE__EXECUTE_TASKS_NEW_PYTHON_INTERPRETER: True |
243 | | - AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres?options=-csearch_path%3Dairflow |
244 | | - AIRFLOW__DATABASE__SQL_ALCHEMY_SCHEMA: airflow |
245 | | - AIRFLOW__WEBSERVER__SECRET_KEY: "test" |
246 | | - AIRFLOW__API__AUTH_BACKENDS: airflow.api.auth.backend.basic_auth |
247 | | - AIRFLOW_CONN_POSTGRES_DB_CONN: postgresql+psycopg2://postgres:postgres@db:5432/postgres |
248 | | - STORAGE_TYPE: minio |
249 | | - AIRFLOW_VAR_MINIO_ENDPOINT: http://minio:9000 |
250 | | - AIRFLOW_VAR_MINIO_ACCESS_KEY: minioadmin |
251 | | - AIRFLOW_VAR_MINIO_SECRET_KEY: minioadmin |
252 | | - AIRFLOW_VAR_WASB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1 |
253 | 257 | AIRFLOW_DEBUG_MODE: True |
254 | | - volumes: |
255 | | - - ./app/airflow/dags:/opt/airflow/dags |
256 | 258 |
|
257 | 259 | volumes: |
258 | 260 | db_data: |
|
0 commit comments