# Standalone database compose for dedicated DB node.
# Deploy this on a separate server when using the "remote databases" topology.
#
# Usage:
#   cp .env.example .env && editor .env
#   docker compose --profile all up -d          # start all DBs
#   docker compose --profile elasticsearch up -d # start only ES
#   docker compose --profile postgres up -d      # start only PG + initdb
#   docker compose --profile mongo up -d         # start only MongoDB
#
# After first run, remove or disable the 'initdb' service to prevent re-initialization.

services:
  elasticsearch:
    image: "registry.on-premise.itarian.com/op-elasticsearch:1.0.1"
    profiles: ["elasticsearch", "all"]
    ports:
      - "${ELASTICSEARCH_PORT:-9200}:9200"
    environment:
      - network.publish_host=${ELASTICSEARCH_PUBLISH_HOST:-}
    volumes:
      - "${DATA_DIR:-/opt/itsm-db}/elasticsearch:/usr/share/elasticsearch/data"
    restart: always

  postgres:
    image: "registry.on-premise.itarian.com/op-postgres:13.14"
    profiles: ["postgres", "all"]
    ports:
      - "${POSTGRES_PORT:-5432}:5432"
    environment:
      POSTGRES_USER: ${POSTGRES_ROOT_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_ROOT_PASSWORD:-postgres}
    volumes:
      - "${DATA_DIR:-/opt/itsm-db}/postgres:/var/lib/postgresql/data"
    restart: always

  initdb:
    image: "registry.on-premise.itarian.com/op-initdb:1.2.0"
    profiles: ["postgres", "all"]
    environment:
      POSTGRES_ROOT_USER: ${POSTGRES_ROOT_USER:-postgres}
      POSTGRES_ROOT_PASSWORD: ${POSTGRES_ROOT_PASSWORD:-postgres}
    depends_on:
      - postgres

  mongo:
    image: "registry.on-premise.itarian.com/op-mongo:4.4.29"
    profiles: ["mongo", "all"]
    ports:
      - "${MONGO_PORT:-27017}:27017"
    volumes:
      - "${DATA_DIR:-/opt/itsm-db}/mongo:/data/db"
    restart: always
    command: --quiet

networks:
  default:
    name: itsm-db
