---
services:
  unit-lint:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
      target: unit-lint
      secrets:
        - github_auth
    hostname: direct_delivery_unit_tests
    environment:
      - Environment=testing
      - DD_DB_HOST=test-dd-db
      - DD_DB_EO_USERNAME=${TEST_DD_USER}
      - DD_DB_EO_PASSWORD=${TEST_DD_PASS}
      - DD_DB_RO_USERNAME=${TEST_DD_USER}
      - DD_DB_RO_PASSWORD=${TEST_DD_PASS}
      - DD_DB_RW_USERNAME=${TEST_DD_USER}
      - DD_DB_RW_PASSWORD=${TEST_DD_PASS}
      - AR_DB_HOST=test-ar-db
      - AR_DB_USERNAME=${TEST_DB_USER}
      - AR_DB_PASSWORD=${TEST_DB_PASS}
      - AR_DB_PORT=3306
      - TEST_FTP_PASS=${TEST_FTP_PASS}
      - AWS_KEY=123
      - AWS_SECRET=xyz
      - AWS_REGION=us-east-1
      - PHYSICAL_LOCATION_ID=1
      - ENCODING_PRIORITIES=1,2,3
      - ALLOWED_ENCODER_IDS=18
      - TEST_FILTER
      - SKIP_LINT
      - SKIP_COVERAGE
      - MODE=unit
      - ECHO_STEPS=0
      - LOG_LEVEL=500
      - EFS_PATH=/mnt/efs
      - ANT_OPTS=-Djdk.lang.Process.launchMechanism=vfork
      - TEST_ENCODER_OUTPUT_DIR=${TEST_ENCODER_OUTPUT_DIR}
    volumes:
      - ./build/logs/:/var/app/build/logs
      - "./tests/fixtures/:${TEST_ASSET_INPUT_DIR:-/tmp/test_fixtures}"
      # mount output to host for debugging - not Jenkins compatible
      # - "./tests/output/:${TEST_ENCODER_OUTPUT_DIR}"
      - delivery-efs:/mnt/efs
    env_file:
      - .env
    depends_on:
      test-ar-db:
        condition: service_healthy
      test-dd-db:
        condition: service_healthy
      test-sftp:
        condition: service_healthy
      # test-ftp:
      #   condition: service_healthy
      moto:
        condition: service_healthy
      test-gcs:
        condition: service_healthy
      cache:
        condition: service_healthy
