# 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.

version: '2.1'

services:
  influxdb:
    image: influxdb:1.7.9
    expose:
      - 8086
    networks:
      - e2e
    healthcheck:
      test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8086"]
      interval: 5s
      timeout: 60s
      retries: 120

  oap:
    extends:
      file: ../base-compose.yml
      service: oap
    environment:
      SW_STORAGE: ${SW_STORAGE}
      SW_KAFKA_FETCHER: default
      SW_KAFKA_FETCHER_SERVERS: broker-a:9092,broker-b:9092
      SW_KAFKA_FETCHER_PARTITIONS: 2
      SW_KAFKA_FETCHER_PARTITIONS_FACTOR: 1
    depends_on:
      influxdb:
        condition: service_healthy
      broker-a:
        condition: service_healthy
      broker-b:
        condition: service_healthy

  provider_kafka:
    build:
      context: ../../../
      dockerfile: e2e-test/docker/kafka/Dockerfile.provider
      args:
        - SW_AGENT_JDK_VERSION=${SW_AGENT_JDK_VERSION}
    networks:
      - e2e
    expose:
      - 9090
    volumes:
      - ../../../../jacoco:/jacoco
    environment:
      SW_AGENT_NAME: e2e-profile-service
      SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
      SW_KAFKA_BOOTSTRAP_SERVERS: broker-a:9092,broker-b:9092
      SW_GET_TOPIC_TIMEOUT: 60
      JAVA_OPTS: >-
        -javaagent:/jacoco/jacocoagent.jar=classdumpdir=/jacoco/classes/provider,destfile=/jacoco/provider.exec,includes=org.apache.skywalking.*,excludes=org.apache.skywalking.apm.dependencies.*
        -javaagent:/skywalking/agent/skywalking-agent.jar=logging.output=CONSOLE
    healthcheck:
      test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 9090"]
      interval: 5s
      timeout: 60s
      retries: 120
    depends_on:
      oap:
        condition: service_healthy
      broker-a:
        condition: service_healthy
      broker-b:
        condition: service_healthy

networks:
  e2e:
