# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # --- x-airflow-common: &airflow-common image: ${AIRFLOW_IMAGE_NAME} env_file: - ${ENV_FILE_PATH:-.env} environment: &airflow-common-env AIRFLOW__CORE__EXECUTOR: LocalExecutor # yamllint disable rule:line-length AIRFLOW__CORE__AUTH_MANAGER: 'airflow.api_fastapi.auth.managers.simple.simple_auth_manager.SimpleAuthManager' AIRFLOW__CORE__SIMPLE_AUTH_MANAGER_ALL_ADMINS: 'true' AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow AIRFLOW__CORE__FERNET_KEY: ${FERNET_KEY} AIRFLOW__CORE__LOAD_EXAMPLES: 'false' AIRFLOW__CORE__DAGS_FOLDER: '/opt/airflow/dags' AIRFLOW__CORE__EXECUTION_API_SERVER_URL: 'http://airflow-apiserver:8080/execution/' AIRFLOW__API__BASE_URL: 'http://airflow-apiserver:8080/' AIRFLOW__API_AUTH__JWT_SECRET: 'test-secret-key-for-testing' AIRFLOW_VAR_TEST_VARIABLE_KEY: 'test_variable_value' AIRFLOW_CONN_TEST_CONNECTION: 'postgresql://testuser:testpass@testhost:5432/testdb' HOST_OS: ${HOST_OS:-linux} user: "${AIRFLOW_UID:-50000}:0" volumes: - ./dags:/opt/airflow/dags - ./logs:/opt/airflow/logs depends_on: &airflow-common-depends-on postgres: condition: service_healthy services: postgres: image: postgres:13 environment: POSTGRES_USER: airflow POSTGRES_PASSWORD: airflow POSTGRES_DB: airflow healthcheck: test: ["CMD", "pg_isready", "-U", "airflow"] interval: 10s retries: 5 start_period: 5s restart: always airflow-init: <<: *airflow-common entrypoint: /bin/bash command: - -c - | echo "Creating missing opt dirs if missing:" mkdir -v -p /opt/airflow/{logs,dags,plugins,config} echo "Airflow version:" /entrypoint airflow version echo "Running airflow config list to create default config file if missing." /entrypoint airflow config list >/dev/null if [ "${HOST_OS}" == "linux" ]; then echo "Change ownership of files in /opt/airflow to ${AIRFLOW_UID}:0" chown -R "${AIRFLOW_UID}:0" /opt/airflow/ else: echo "Skipping changing ownership as platform is not linux (${HOST_OS})" fi environment: <<: *airflow-common-env _AIRFLOW_DB_MIGRATE: 'true' _AIRFLOW_WWW_USER_CREATE: 'true' _AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow} _AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow} _PIP_ADDITIONAL_REQUIREMENTS: '' user: "0:0" depends_on: <<: *airflow-common-depends-on airflow-apiserver: <<: *airflow-common command: api-server ports: - "8080:8080" healthcheck: test: ["CMD", "curl", "--fail", "http://localhost:8080/api/v2/monitor/health"] interval: 30s timeout: 10s retries: 5 start_period: 30s restart: always depends_on: <<: *airflow-common-depends-on airflow-init: condition: service_completed_successfully airflow-scheduler: <<: *airflow-common command: scheduler healthcheck: test: ["CMD", "airflow", "jobs", "check", "--job-type", "SchedulerJob"] interval: 30s timeout: 10s retries: 5 restart: always depends_on: postgres: condition: service_healthy airflow-init: condition: service_completed_successfully airflow-dag-processor: <<: *airflow-common command: dag-processor depends_on: <<: *airflow-common-depends-on airflow-init: condition: service_completed_successfully