version: '3.7'

services:
  ## EDMI
  # MySQL
  edmi-db:
    image: hub.eltex-co.ru/edm/edmi-db:${EDM_TAG}
    command: --max_allowed_packet=16777216
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - TZ=${COMMON_TZ:-UTC}
      - MYSQL_USER=${EDM_DB_USER:-edm}
      - MYSQL_PASSWORD=${EDM_DB_PASSWORD}
    networks:
      - edmi-network
    restart: always

  # Init
  edmi-init:
    image: hub.eltex-co.ru/edm/edmi-init:${EDM_TAG}
    volumes:
      - ./config/edmi:/etc/edmi
      - ./config/edmi-cli:/etc/edmi-cli
      - ./log/edmi:/var/log/edmi
      - ./log/edmi-cli:/var/log/edmi-cli
      - ./db:/var/lib/mysql
      - edmi-healthcheck:/tmp/healthcheck
    environment:
      - TZ=${COMMON_TZ:-UTC}
      - EDM_DB_USER=${EDM_DB_USER:-edm}
      - EDM_DB_PASSWORD
      - EDM_LOADER_HOST_TITLE
      - EDM_SERVER_HOST_TITLE
      - EDM_SERVER_HOST_IP
      - EDM_THREAD_LIMIT
      - EDM_QUEUE_LIMIT
      - EDM_DEVICE_MAX_TIMEOUT
      - EDM_DEVICE_WAIT_REQUEST_TIMEOUT
      - EDM_INACTIVE_HOSTS_KEEP_DAYS
      - EDM_WEB_SESSION_MAX_HOURS
      - EDM_WEB_SESSION_REMEMBERED_MAX_HOURS
      - EDM_DOS_FILTER_MAX_REQUESTS_PER_SECOND
      - EDM_DOS_FILTER_DELAY_MS
      - EDM_SECURITY_CHECK_PERIOD_HOURS
      - EDM_SOURCE_UNKNOWN_REQUEST_LIMIT
      - EDM_BAD_AUTH_LIMIT
      - EDM_ROOT_URL
      - EDM_LICENSE_KEY
      - EDM_LOADER_HOST_PROTECTED_MODE
      - EDM_DEVICE_ROOT_TIMEOUT
      - EDM_USER_LOGIN_TIMEOUT
      - EDM_USER_INACTIVE_TIMEOUT
      - EDM_COMMANDS_EXECUTE_TIMEOUT_MINUTES
      - EDM_LOG_FILE_MAX_SIZE=${EDM_LOG_FILE_MAX_SIZE:-10}
      - EDM_LOG_FILE_MAX_COUNT=${EDM_LOG_FILE_MAX_COUNT:-4}
      - EDM_KERNEL_LOG_LEVEL=${EDM_KERNEL_LOG_LEVEL:-info}
      - EDM_DEBUG_LOG_LEVEL=${EDM_DEBUG_LOG_LEVEL:-off}
      - EDM_ENGINE_LOG_LEVEL=${EDM_ENGINE_LOG_LEVEL:-info}
      - EDM_DB_LOG_LEVEL=${EDM_DB_LOG_LEVEL:-info}
      - EDM_NETWORKING_LOG_LEVEL=${EDM_NETWORKING_LOG_LEVEL:-info}
      - EDM_SECURITY_LOG_LEVEL=${EDM_SECURITY_LOG_LEVEL:-info}
      - EDM_HOSTS_LOG_LEVEL=${EDM_HOSTS_LOG_LEVEL:-info}
      - EDM_USERS_LOG_LEVEL=${EDM_USERS_LOG_LEVEL:-info}
      - EDM_COMMERCE_LOG_LEVEL=${EDM_COMMERCE_LOG_LEVEL:-info}
      - EDM_CLI_KERNEL_LOG_LEVEL=${EDM_CLI_KERNEL_LOG_LEVEL:-error}
      - EDM_CLI_DEBUG_LOG_LEVEL=${EDM_CLI_DEBUG_LOG_LEVEL:-off}
      - EDM_CLI_ENGINE_LOG_LEVEL=${EDM_CLI_ENGINE_LOG_LEVEL:-error}
      - EDM_CLI_DB_LOG_LEVEL=${EDM_CLI_DB_LOG_LEVEL:-error}
      - EDM_CLI_NETWORKING_LOG_LEVEL=${EDM_CLI_NETWORKING_LOG_LEVEL:-error}
      - EDM_CLI_SECURITY_LOG_LEVEL=${EDM_CLI_SECURITY_LOG_LEVEL:-error}
      - EDM_CLI_HOSTS_LOG_LEVEL=${EDM_CLI_HOSTS_LOG_LEVEL:-error}
      - EDM_CLI_USERS_LOG_LEVEL=${EDM_CLI_USERS_LOG_LEVEL:-error}
      - EDM_CLI_COMMERCE_LOG_LEVEL=${EDM_CLI_COMMERCE_LOG_LEVEL:-error}
      - EDM_CLI_RESOURCES_LOG_LEVEL=${EDM_CLI_RESOURCES_LOG_LEVEL:-error}
    networks:
      - edmi-network
    security_opt:
      - seccomp:unconfined
    depends_on:
      - edmi-db

  # Server daemon
  edmi-server:
    image: hub.eltex-co.ru/edm/edmi-server:${EDM_TAG}
    volumes:
      - ./config/edmi:/etc/edmi
      - ./log/edmi:/var/log/edmi
      - edmi-healthcheck:/tmp/healthcheck
    environment:
      - TZ=${COMMON_TZ:-UTC}
    ports:
      - ${EDM_SERVER_HOST_PORT:-8098}:8098
    networks:
      - edmi-network
    security_opt:
      - seccomp:unconfined
    depends_on:
      - edmi-init
      - edmi-db
    restart: always

  # Loader daemon
  edmi-loader:
    image: hub.eltex-co.ru/edm/edmi-loader:${EDM_TAG}
    volumes:
      - ./config/edmi:/etc/edmi
      - ./log/edmi:/var/log/edmi
      - edmi-healthcheck:/tmp/healthcheck
    environment:
      - TZ=${COMMON_TZ:-UTC}
    networks:
      - edmi-network
    security_opt:
      - seccomp:unconfined
    depends_on:
      - edmi-init
      - edmi-db
    restart: always

volumes:
  edmi-healthcheck:
    driver: local
    driver_opts:
      type: tmpfs
      device: tmpfs

networks:
  edmi-network:
    name: edmi-network
    driver: bridge
