services:
  postgres:
    image: postgres:17-alpine
    environment:
      POSTGRES_DB: morz_infoboard
      POSTGRES_USER: morz_infoboard
      POSTGRES_PASSWORD: morz_infoboard
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U morz_infoboard"]
      interval: 5s
      timeout: 5s
      retries: 10

  mosquitto:
    image: eclipse-mosquitto:2
    ports:
      - "1883:1883"
    volumes:
      - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro

  backend:
    build:
      context: ../server/backend
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    environment:
      MORZ_INFOBOARD_HTTP_ADDR: ":8080"
      MORZ_INFOBOARD_DATABASE_URL: "postgres://morz_infoboard:morz_infoboard@postgres:5432/morz_infoboard?sslmode=disable"
      MORZ_INFOBOARD_UPLOAD_DIR: "/uploads"
      MORZ_INFOBOARD_MQTT_BROKER: "tcp://mosquitto:1883"
      MORZ_INFOBOARD_ADMIN_PASSWORD: "${MORZ_INFOBOARD_ADMIN_PASSWORD}"
      MORZ_INFOBOARD_DEV_MODE: "${MORZ_INFOBOARD_DEV_MODE:-false}"
      MORZ_INFOBOARD_DEFAULT_TENANT: "${MORZ_INFOBOARD_DEFAULT_TENANT:-morz}"
    volumes:
      - uploads:/uploads
    depends_on:
      postgres:
        condition: service_healthy
      mosquitto:
        condition: service_started
    restart: unless-stopped

volumes:
  postgres-data:
  uploads:
