version: '3'

name: irods-demo

services:
    irods-catalog:
        build:
            context: irods_catalog
        # 5432 is exposed by default and can conflict with other postgres containers.
        # When the metalnx-db service is no longer needed, this stanza can be removed.
        ports:
            - "5430:5432"
        environment:
            - POSTGRES_PASSWORD=testpassword

    irods-catalog-provider:
        build:
            context: irods_catalog_provider
        shm_size: 500mb
        healthcheck:
            test: ["CMD", "su", "-", "irods", "-c", "ils || exit 1"]
            interval: 10s
            timeout: 10s
            retries: 3
            start_period: 20s
            start_interval: 2s
        depends_on:
            - irods-catalog

    irods-client-icommands:
        build:
            context: irods_client_icommands
        depends_on:
            irods-catalog-provider:
                condition: service_healthy

    irods-client-http-api:
        image: irods/irods_http_api:0.2.0
        volumes:
            - ./irods_client_http_api/config.json:/config.json:ro
        ports:
            - "9001:9000"
        restart: on-failure
        depends_on:
            irods-catalog-provider:
                condition: service_healthy

    irods-client-rest-cpp:
        build:
            context: irods_client_rest_cpp
            dockerfile: irods_client_rest_cpp.Dockerfile
        volumes:
            - ./irods_client_rest_cpp/irods_client_rest_cpp.json:/etc/irods_client_rest_cpp/irods_client_rest_cpp.json:ro
        depends_on:
            irods-catalog-provider:
                condition: service_healthy

    nginx-reverse-proxy:
        build:
            context: irods_client_rest_cpp
            dockerfile: nginx.Dockerfile
        ports:
            - "80:80"
        depends_on:
            - irods-client-rest-cpp
