services:

  rabbitmq:
    image: rabbitmq:3-management
    hostname: rabbitmq
    container_name: rabbitmq
    volumes:
      - ./init/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
      - ./init/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro
    ports:
      - "5672:5672"
      - "15672:15672"
    networks:
      - backend
    healthcheck:
      test: rabbitmq-diagnostics check_port_connectivity
      interval: 30s
      timeout: 30s
      retries: 10

  server:
    build:
      context: .
      dockerfile: ./cmd/server/Dockerfile
    command: [ '--mode=container', '--loglevel=debug' ]
    container_name: server
    stop_grace_period: 1s
    ports:
      # - "8081:8080" # host:container for proxy
      - "8080:8080" # host:container
    depends_on:
      - rabbitmq
      - dbstore
      - artifactstore
    networks:
      - backend
    env_file:
      - path: ./.env.container
        required: true

  dbstore:
    image: minio/minio:RELEASE.2024-06-11T03-13-30Z
    container_name: dbstore
    ports:
      - "9000:9000"
      - "9001:9001"
    env_file:
      - path: .env.container
        required: true
    command: server /data --console-address ":9001"
    volumes:
      - ./dbstore-data:/data
    networks:
      - backend

  artifactstore:
    image: minio/minio:RELEASE.2024-06-11T03-13-30Z
    container_name: artifactstore
    ports:
      - "19000:9000" # host:container
      - "19001:9001"
    env_file:
      - path: ./.env.container
        required: true
    command: server /data --console-address ":9001"
    volumes:
      - ./qpstore-data:/data
    networks:
      - backend

  agent:
    build:
      context: .
      dockerfile: ./cmd/agent/Dockerfile
    command: [ '--loglevel=debug' ]
    container_name: agent
    depends_on:
      - rabbitmq
      - dbstore
      - artifactstore
    env_file:
      - path: ./.env.container
        required: true
    networks:
      - backend

networks:
  backend:
    driver: bridge
