services:
    mrvadata:
        image: ghcr.io/hohn/mrvadata:0.1.24
        container_name: mrvadata
        volumes:
            - mrvadata:/data/mrvacommander/dbstore-data
        networks:
            - backend
            
    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/mrvacommander/dbstore-data --console-address ":9001"
        depends_on:
            - mrvadata
        # The mrvadata volume has content of ./dbstore-data, so the volume mount
        # below is equivalent of this original:
        # volumes:        
        #     - ./dbstore-data:/data
        volumes:
            - mrvadata:/data
        networks:
            - backend
     
    client-qldbtools:
        image: ghcr.io/hohn/client-qldbtools-container:0.1.24 
        # XX: Copy client/qldbtools/scratch into this container
        networks:
            - backend
            

    client-ghmrva:
        # XX: redirect by changing code or using nginx proxy
        # client.Get(fmt.Sprintf("http://localhost:8080/repos/%s/code-scanning/codeql/variant-analyses/%d", controller, runId), &response)
        image: ghcr.io/hohn/client-ghmrva-container:0.1.24 
        # XX: Include codeql in container if needed; no attached storage container.
        networks:
            - backend
            
    code-server:
        image: ghcr.io/hohn/code-server-initialized:0.1.24
        ports:
            - "9080:9080"
        # XX: Include codeql binary in code-server (if it's not there already)
        environment:
            - PASSWORD=mrva
     
    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"
        healthcheck:
          test: rabbitmq-diagnostics check_port_connectivity
          interval: 30s
          timeout: 30s
          retries: 10
        networks:
            - backend
     
    server:
        image: ghcr.io/hohn/mrva-server:0.1.24
        command: [ '--mode=container', '--loglevel=debug' ]
        container_name: server
        stop_grace_period: 1s
        ports:
            - "8080:8080" # host:container
        depends_on:
            - rabbitmq
            - dbstore
            - artifactstore
        env_file:
            - path: ./.env.container
              required: true
        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:
            # The artifactstore is only populated at runtime so there is no need
            # for Docker storage; a directory is fine.
            - ./qpstore-data:/data
        networks:
            - backend
     
    agent:
        image: ghcr.io/hohn/mrva-agent:0.1.24
        command: [ '--loglevel=debug' ]
        container_name: agent
        depends_on:
            - rabbitmq
            - dbstore
            - artifactstore
        env_file:
            - path: ./.env.container
              required: true
        networks:
            - backend
   
networks:
    backend:
        driver: bridge

volumes:
    mrvadata:
