name: ix-databases

networks:
  shared-databases:
    driver: bridge

services:

  postgres:
    container_name: shared-postgres
    image: ghcr.io/immich-app/postgres:17-vectorchord0.5.3-pgvector0.8.1
    restart: unless-stopped
    networks:
      - shared-databases
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - /mnt/docker-ssd/docker/databases/postgres:/var/lib/postgresql/data
      - /mnt/docker-ssd/docker/compose/databases/initdb:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 30s

  mariadb:
    container_name: shared-mariadb
    image: mariadb:11.4
    restart: unless-stopped
    networks:
      - shared-databases
    ports:
      - "3306:3306"
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
      UPTIMEKUMA_DB_NAME: ${UPTIMEKUMA_DB_NAME}
      UPTIMEKUMA_DB_USER: ${UPTIMEKUMA_DB_USER}
      UPTIMEKUMA_DB_PASS: ${UPTIMEKUMA_DB_PASS}
    volumes:
      - /mnt/docker-ssd/docker/databases/mariadb:/var/lib/mysql
      - /mnt/docker-ssd/docker/compose/databases/initdb-mariadb:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 30s

  redis:
    container_name: shared-redis
    image: redis:7-alpine
    restart: unless-stopped
    networks:
      - shared-databases
    ports:
      - "6379:6379"
    command: >
      sh -c "redis-server --appendonly yes --requirepass '${REDIS_PASSWORD}'"
    volumes:
      - /mnt/docker-ssd/docker/databases/redis:/data
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 10s
