services:
  dmarc-report:
    image: "gutmensch/dmarc-report:latest"
    hostname: dmarc-report
    container_name: dmarc-report
    restart: always
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "80:80"
    environment:
      - "REPORT_DB_HOST=${DB_HOST:-db}"
      - "REPORT_DB_TYPE=${DB_TYPE:-mysql}"
      - "REPORT_DB_PORT=${DB_PORT:-3306}"
      - "REPORT_DB_NAME=${DB_NAME:-dmarc_report}"
      - "REPORT_DB_USER=${DB_USER:-dmarc_report}"
      - "REPORT_DB_PASS=${DB_PASSWORD}"
      - "PARSER_IMAP_SERVER=${IMAP_SERVER}"
      - "PARSER_IMAP_PORT=${IMAP_PORT:-993}"
      - "PARSER_IMAP_USER=${IMAP_USER}"
      - "PARSER_IMAP_PASS=${IMAP_PASSWORD}"
      - "PARSER_IMAP_READ_FOLDER=${IMAP_READ_FOLDER:-Inbox}"
      - "PARSER_IMAP_MOVE_FOLDER=${IMAP_MOVE_FOLDER:-processed}"
      - "PARSER_IMAP_MOVE_FOLDER_ERR=${IMAP_MOVE_FOLDER_ERR:-error}"
      - "PARSER_IMAP_SSL=${PARSER_IMAP_SSL}"
      - "PARSER_IMAP_TLS=${PARSER_IMAP_TLS}"
      - "PARSER_IMAP_IGNORE_ERROR=${PARSER_IMAP_IGNORE_ERROR}"
      - "PARSER_XML_MAXSIZE=${PARSER_XML_MAXSIZE}"

  db:
    image: mariadb:10
    command: --skip-innodb-read-only-compressed
    restart: always
    environment:
      - "MYSQL_ROOT_PASSWORD=${ROOT_DB_PASSWORD}"
      - "MYSQL_DATABASE=${DB_NAME:-dmarc_report}"
      - "MYSQL_USER=${DB_USER:-dmarc_report}"
      - "MYSQL_PASSWORD=${DB_PASSWORD}"
    volumes:
      - ./run/db:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${ROOT_DB_PASSWORD}"]
      interval: 10s
      timeout: 10s
      retries: 5
