# InfluxDB v2 - Time-series database for Smart City IoT analytics
# Usage: docker compose -f docker-compose.influxdb.yml up -d

networks:
  smartcity-shared:
    external: true
  traefik-public:
    external: true

volumes:
  influxdb_data:
    external: false
    name: digital-twin_influxdb_data

services:
  influxdb:
    image: influxdb:2.7-alpine
    container_name: smart-city-influxdb
    networks:
      - smartcity-shared
      - traefik-public
    ports:
      - "8086:8086"
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=admin1234
      - DOCKER_INFLUXDB_INIT_ORG=digitribe
      - DOCKER_INFLUXDB_INIT_BUCKET=iot_data
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-admin-token
    volumes:
      - influxdb_data:/var/lib/influxdb2
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "influx", "ping"]
      interval: 30s
      timeout: 10s
      retries: 5
