x-default_php_setup:
  &default_php_setup
  image: php${PHP_HASH}
  networks:
    - test-network

x-healthcheck_web:
  &healthcheck_web
  healthcheck:
    test: ${DEFAULT_WEB_HEALTHCHECK_COMMAND}
    interval: ${DEFAULT_HEALTHCHECKS_INTERVAL}
    timeout: ${DEFAULT_HEALTHCHECKS_TIMEOUT}
    start_period: ${DEFAULT_HEALTHCHECKS_START_PERIOD}
    retries: ${DEFAULT_HEALTHCHECKS_RETRIES}

services:
  # Apache container for the xxe module and its endpoint
  xxe:
    <<: [ *default_php_setup, *healthcheck_web ]
    depends_on:
      endpoint:
        condition: service_healthy
    volumes:
      - ./test_mod_xxe/php/src/:/var/www/html/

  # Custom endpoint for requests
  endpoint:
    build:
      context: ../../
      dockerfile: "tests/integration/endpoint/Dockerfile"
      args:
        PHP_HASH_TAG: ${PHP_HASH}
    <<: *healthcheck_web
    networks:
      - test-network

  # Wapiti container 
  # requires all the targets containers to work perfectly
  wapiti:
    build:
      context: "../../"
      dockerfile: "./tests/integration/wapiti/Dockerfile.integration"
      no_cache: true
    container_name: wapiti
    volumes:
      - ./.test:/home/
    networks:
      - test-network
    command: "${TESTS}"
    depends_on:
      xxe:
        condition: service_healthy

networks:
  test-network:
