#
# 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: '3.3'

services:
  middleware:
    build:
      context: ./middleware
    container_name: middleware
    network_mode: "host"
    ports:
      - "3002:3002" # Expose middleware service on port 3002
    depends_on:
      - pyroscope-client
      - process-exporter

  pyroscope-server:
    build:
      context: ./pyroscope
    container_name: pyroscope-server
    network_mode: "host"
    environment:
      - ROLE=server
    ports:
      - "4040:4040"
    volumes:
      - ./pyroscope-data:/host/pyroscope-data # Mount host filesystem for storage
    privileged: true # Required for eBPF and accessing host resources

  pyroscope-client:
    build:
      context: ./pyroscope
    container_name: pyroscope-client
    network_mode: "host" # Allows access to the host network
    environment:
      - ROLE=client
      - PYROSCOPE_SERVER_ADDRESS=http://0.0.0.0:4040 # Pyroscope server running on the host
    privileged: true 
    pid: "host"

  process-exporter:
    build:
      context: ./process-exporter
    container_name: process-exporter
    privileged: true
    ports:
      - "9256:9256"
    volumes:
      - /proc:/host/proc
      - ./process-exporter:/config
