Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
6.1 kB
1
Indexable
Never
# 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.
# airflow tasks test restaurants_reports brand_stages 2023-12-07
# airflow dags test position_store_rte 2023-12-07
 
# Basic Airflow cluster configuration for CeleryExecutor with Redis and PostgreSQL.
#
# WARNING: This configuration is for local development. Do not use it in a production deployment.
#
# This configuration supports basic configuration using environment variables or an .env file
# The following variables are supported:
#
# AIRFLOW_IMAGE_NAME         - Docker image name used to run Airflow.
#                              Default: apache/airflow:master-python3.8
# AIRFLOW_UID                - User ID in Airflow containers
#                              Default: 50000
# AIRFLOW_GID                - Group ID in Airflow containers
#                              Default: 50000
# _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account.
#                              Default: airflow
# _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account.
#                              Default: airflow
#
# Feel free to modify this file to suit your needs.
---
version: '3'
x-airflow-common:
  &airflow-common
  platform: linux/arm64/v8
  build:
    context: "/Users/avsatov.ae/Code/WORK/analytics-dags/"
    dockerfile: Dockerfile
  environment:
    &airflow-common-env
    AIRFLOW__CORE__EXECUTOR: LocalExecutor
    AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
    AIRFLOW__CORE__FERNET_KEY: ''
    AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
    AIRFLOW__CORE__LOAD_EXAMPLES: 'false'
    AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT: 300
  sysctls:
    - net.ipv4.tcp_keepalive_time=200
    - net.ipv4.tcp_keepalive_intvl=200
    - net.ipv4.tcp_keepalive_probes=5
  volumes:
    - ./dags/finance/dags/restaurants_reports.py:/opt/airflow/dags/restaurants_reports.py
    - ./dags/finance/dags/test_dag_vadim.py:/opt/airflow/dags/test_dag_vadim.py
#    здесь происходит импорт дагов, модулей и библиотек
    - ./libs:/opt/airflow/dags/libs
    - ./logs:/opt/airflow/logs
    - ./plugins:/opt/airflow/plugins
    - /opt/airflow/dags/venv
    - ./../config:/opt/config
    - ./CA/CA.pem:/opt/airflow/CA.pem #путь к сертификату подключения нужен для подключения к клику
  user: "${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}"
  depends_on:
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy
 
 
services:
  postgres:
    image: postgres:13
    environment:
      POSTGRES_USER: airflow
      POSTGRES_PASSWORD: airflow
      POSTGRES_DB: airflow
    volumes:
      - postgres-db-volume:/var/lib/postgresql/data
    healthcheck:
      test: [ "CMD", "pg_isready", "-U", "airflow" ]
      interval: 5s
      retries: 5
    restart: always
 
  redis:
    image: redis:latest
    ports:
      - 6379:6379
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 5s
      timeout: 30s
      retries: 50
    restart: always
 
  airflow-webserver:
    <<: *airflow-common
    command: webserver
    ports:
      - 8080:8080
    healthcheck:
      test: [ "CMD", "curl", "--fail", "http://localhost:8080/health" ]
      interval: 10s
      timeout: 10s
      retries: 5
    restart: always
 
  airflow-init:
    <<: *airflow-common
    command:
      - bash
      - -c
      - |
        airflow version
        airflow connections delete 'clickhous_analytics'
        airflow connections add 'clickhous_analytics' \
            --conn-type 'clickhouse' \
            --conn-login 'aleksandr_avsatov' \
            --conn-password 'ZvoFKTwHnrLd4lJ5OsW4kcWqU6UM6TYPnLAVLpGm' \
            --conn-host '10.65.23.82' \
            --conn-port '9440' \
            --conn-schema 'analytics' \
            --conn-extra '{"secure": "true", "ca_certs": "./CA.pem"}'
        airflow connections delete 'nextcloud_key'
        airflow connections add 'nextcloud_key' \
            --conn-type 'aws' \
            --conn-login 'avsatov.ae' \
            --conn-password 'Nt9Mg-oNySA-CMTK5-cpzrA-xe3g3' \
            --conn-host 'https://nextcloud.sbmt.io/'
        airflow connections delete 'mysql_instamart'
        airflow connections add 'mysql_instamart' \
            --conn-type 'mysql' \
            --conn-login 'nikita_patov' \
            --conn-password 'Jy?d^\hIE2W]x!I6M:[0Nc$@=e?uU>.y' \
            --conn-host 'proxysql-main-etl.sbmt.io'\
            --conn-schema 'instamart_production'
        airflow connections delete 'postgres_onbords'
        airflow connections add 'postgres_onbords' \
            --conn-type 'postgres'\
            --conn-login 'vadim-medvedev' \
            --conn-password 'pFbyFIxlyQrFym6hMVWwiATQeYF53O9C' \
            --conn-host 'rc1a-2jkp9qk7mgye17g2.mdb.yandexcloud.net'\
            --conn-schema 'app'\
            --conn-port '6432'
    environment:
      <<: *airflow-common-env #airflow connections delete 'mailgun'
      _AIRFLOW_DB_UPGRADE: 'true'
      _AIRFLOW_WWW_USER_CREATE: 'true'
      _AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
      _AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
      AIRFLOW_IMAGE_NAME: "${AIRFLOW_IMAGE_NAME:-apache/airflow:latest-python3.8}"
 
volumes:
  postgres-db-volume:
Leave a Comment