services:
  postgis:
    image: postgis/postgis:17-3.5-alpine
    environment:
      POSTGRES_USER: reitti
      POSTGRES_PASSWORD: reitti
      POSTGRES_DB: reittidb
    ports:
      - "5432:5432"
    volumes:
      - postgis-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U reitti -d reittidb"]
      interval: 10s
      timeout: 5s
      retries: 5
  rabbitmq:
    image: rabbitmq:3-management-alpine
    ports:
      - "5672:5672"   # AMQP protocol port
      - "15672:15672" # Management UI port
      - "1883:1883" #MQTT port
    post_start:
      - command: rabbitmq-plugins enable rabbitmq_mqtt
        user: root
    environment:
      RABBITMQ_DEFAULT_USER: reitti
      RABBITMQ_DEFAULT_PASS: reitti
    volumes:
      - rabbitmq-data:/var/lib/rabbitmq
    healthcheck:
      test: ["CMD", "rabbitmq-diagnostics", "check_port_connectivity"]
      interval: 30s
      timeout: 10s
      retries: 5
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
  photon:
    image: rtuszik/photon-docker:latest
    environment:
      - UPDATE_STRATEGY=PARALLEL
      - COUNTRY_CODE=de
    ports:
      - "2322:2322"
    volumes:
      - photon-data:/photon/photon_data
  ot-recorder:
    image: owntracks/recorder:latest
    depends_on:
      rabbitmq:
        condition: service_healthy
    environment:
      - OTR_HOST=rabbitmq
      - OTR_USER=reitti
      - OTR_PASS=reitti
    ports:
      - "8083:8083"
    volumes:
      - ot-recorder-data:/store
volumes:
  postgis-data:
  redis-data:
  rabbitmq-data:
  photon-data:
  ot-recorder-data:
