version: '3.8'

services:
  agent-service:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "18880:18880"
      - "9090:9090"  
    environment:
      - SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/agentdb
      - SPRING_DATASOURCE_USERNAME=airavata
      - SPRING_DATASOURCE_PASSWORD=airavata123
      - SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.MariaDBDialect
      - SERVER_PORT=18880
      - AIRAVATA_SERVER_TRUSTSTORE_PATH=/app/conf/truststore.jks
      - airavata.storageResourceId=default-storage-id
    depends_on:
      mariadb:
        condition: service_healthy  
    volumes:
      - ./conf:/app/conf
    networks:
      - agent-network

  mariadb:
    image: mariadb:10.11
    ports:
      - "3307:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=rootpassword
      - MYSQL_DATABASE=agentdb
      - MYSQL_USER=airavata
      - MYSQL_PASSWORD=airavata123
    volumes:
      - mariadb-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 5s
      timeout: 5s
      retries: 20
    networks:
      - agent-network

networks:
  agent-network:
    driver: bridge

volumes:
  mariadb-data: