# Sample docker compose file that uses a PostgreSQL image
# The UI will be available on Port 4280 of your host machine

services:
    neo4j:
        image: docker.ubs-hainer.com/neo4j:4.4
        mem_limit: 3G
        environment:
            - TZ=Europe/Berlin
            - NEO4J_AUTH=neo4j/neo4jpsw
        volumes:
            - ./xdm-neo4j:/data

    core-server:
        image: docker.ubs-hainer.com/xdm3-core:latest
        mem_limit: 2G
        environment:
            - TZ=Europe/Berlin
            - spring.cloud.dataflow.client.serverUri=http://dataflow-server:9393
            - spring.data.neo4j.username=neo4j
            - spring.data.neo4j.password=neo4jpsw
            - spring.data.neo4j.uri=bolt://neo4j
            - admin.db.url=jdbc:postgresql://xdm-db/xdm
            - admin.db.user=xdm
            - admin.db.password=xdm
            - admin.db.schema=public
            - admin.db.driver=org.postgresql.Driver
            - spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
            - xdm.core.liquibase.enabled=true
            - xdm.core.data-type-conversion=true
            - xdm.blob.store.type=file
            - xdm.blob.store.file.directory=/xdm
            - xdm.core.grafana.serverUri=http://grafana:3000/reports/

           # These properties configure the xdm central search
           # - xdm.core.global.search.enabled=true
           # - xdm.core.global.search.port=9200
           # - xdm.core.global.search.hostname=elasticsearch
           # - xdm.core.global.search.password=xdm

        depends_on:
            - neo4j
        volumes:
            - ./xdm-data:/xdm/data
            - ./xdm-config:/xdm/config:ro
            - ./xdm-tasks:/xdm/tasks
            - ./xdm-backups:/xdm/backups
            - ./xdm-mapping:/xdm/mapping

    web-ui:
        image: docker.ubs-hainer.com/xdm3-ui:latest
        mem_limit: 512M
        ports:
            - '4280:80'
        environment:
            - TZ=Europe/Berlin
            - xdm_core_serverUri=http://core-server:8000/api/
            - xdm_grafana_serverUri=http://grafana:3000
        depends_on:
            - core-server

    xdm-db:
        image: docker.ubs-hainer.com/postgres:15
        mem_limit: 512M
        environment:
            - TZ=Europe/Berlin
            - POSTGRES_USER=xdm
            - POSTGRES_PASSWORD=xdm
        volumes:
            - ./pgdata:/var/lib/postgresql/data

    dataflow-server:
        image: docker.ubs-hainer.com/xdm3-dataflow:latest
        mem_limit: 3G
        environment:
            - TZ=Europe/Berlin
            - xdm_core_serverUri=http://core-server:8000/api
            - xdm.core.data-type-conversion=true
            - spring.data.neo4j.username=neo4j
            - spring.data.neo4j.password=neo4jpsw
            - spring.data.neo4j.uri=bolt://neo4j
            - admin.db.url=jdbc:postgresql://xdm-db/xdm
            - admin.db.user=xdm
            - admin.db.password=xdm
            - admin.db.schema=public
            - admin.db.driver=org.postgresql.Driver
            - xdm.blob.store.type=file
            - xdm.blob.store.file.directory=/xdm
            - xdm_loki_serverUri=http://loki:3100
            - xdm_tempo_zipkin_serverUri=http://tempo:9411
        depends_on:
            - core-server
            - xdm-db
        volumes:
            - ./xdm-data:/xdm/data
            - ./xdm-config:/xdm/config:ro
            - ./xdm-tasks:/xdm/tasks
            - ./xdm-backups:/xdm/backups
            - ./modification-lib:/xdm/batch/modification-lib
            - ./xdm-mapping:/xdm/mapping

    grafana:
        image: docker.ubs-hainer.com/xdm3-grafana:latest
        mem_limit: 512M
        volumes:
           - ./grafana:/var/lib/grafana
        environment:
            - POSTGRES_URL=xdm-db:5432
            - POSTGRES_DATABASE=xdm
            - POSTGRES_USER=xdm
            - POSTGRES_PASSWORD=xdm
            - PROMETHEUS_URL=http://prometheus:9090
            - TEMPO_URL=http://tempo:3200
            - LOKI_URL=http://loki:3100
        depends_on:
            - xdm-db

    prometheus:
        image: docker.ubs-hainer.com/xdm3-prometheus:latest
        volumes:
            - ./prometheus:/opt/bitnami/prometheus/data
        environment:
            - CORE_URL=http://core-server:8000
            - DATAFLOW_URL=http://dataflow-server:9393
        #    - GRAPH_STORE_URL=http://graph-store:8000
        #    - GENERATOR_SOURCE_URL=http://generator-source:8000
        #    - FILE_SINK_URL=http://file-sink:8000

    loki:
        image: docker.ubs-hainer.com/xdm3-loki:latest
        volumes:
            - ./loki-data:/loki
        environment:
            - JAEGER_AGENT_HOST=tempo
            - JAEGER_ENDPOINT=http://tempo:14268/api/traces
            - JAEGER_SAMPLER_TYPE=const
            - JAEGER_SAMPLER_PARAM=1

    tempo:
        image: docker.ubs-hainer.com/xdm3-tempo:latest
        volumes:
            - ./tempo-data:/tmp/tempo

#########################################################################################
# Uncomment the following section to activate generation microservices.                 #
# Also uncomment the environment variables for this services in prometheus.             #
#########################################################################################

#    generator-source:
#        image: docker.ubs-hainer.com/xdm3-generator-source:latest
#        mem_limit: 2G
#        environment:
#            - TZ=Europe/Berlin
#            - JAVA_TOOL_OPTION="-XX:MaxDirectMemorySize=128M"

#    file-sink:
#        image: docker.ubs-hainer.com/xdm3-file-sink:latest
#        mem_limit: 1G
#        user: "1001:1002"
#        environment:
#            - TZ=Europe/Berlin
#        volumes:
#            - ./file-sink-data:/workspace/data

#########################################################################################
# Uncomment the following section to activate webservice microservices.                 #
# Also uncomment the environment variables for this services in prometheus.             #
#########################################################################################

#    graph-store:
#        image: docker.ubs-hainer.com/xdm3-graph-store:latest
#        mem_limit: 1536M
#        user: "1001:1002"
#        environment:
#            - TZ=Europe/Berlin
#        volumes:
#            - ./graph-data:/workspace/data

#########################################################################################
# Uncomment the following section to activate the central XDM search.                   #
# Also uncomment the properties: xdm.core.global.search.*                               #
# under services -> core-server -> environment.                                         #
#########################################################################################

#    elasticsearch:
#        image: docker.ubs-hainer.com/elasticsearch:7.17.25
#        volumes:
#             - ./elasticsearch:/usr/share/elasticsearch/data:rw
#        environment:
#            - discovery.type=single-node
#            - cluster.name=elasticsearch
#            - node.name=es1
#            - xpack.security.enabled=true
#            - ELASTIC_PASSWORD=xdm

#########################################################################################
# Uncomment ALL the following lines to start the sample environment                     #
# alongside XDM. To uncomment, DELETE the first character (pound symbol - "#") in each  #
# line, but DO NOT delete or add any spaces and DO NOT add any tabs.                    #
#########################################################################################

#    sample-ssh:
#        image: docker.ubs-hainer.com/linuxserver/openssh-server:version-9.0_p1-r2
#        environment:
#            - PUID=1000
#            - PGID=1000
#            - USER_NAME=sshuser
#            - USER_PASSWORD=pass123ssh
#            - PASSWORD_ACCESS=true
#        volumes:
#            - ./sample-shared:/xdmdata
#
#    sample-pg:
#        image: docker.ubs-hainer.com/sample-environment:latest
#        environment:
#            - TZ=Europe/Berlin
#            - POSTGRES_PASSWORD=pass123postgres
#        volumes:
#            - ./sample-shared:/xdmdata