Files
unpoller-unpoller-3/init/docker/docker-compose.yml
Cody Lee b960695f3b Add Docker health check support
Implements #406 by adding a --health CLI flag and HEALTHCHECK instruction
to the Dockerfile. This allows Docker and container orchestration platforms
to monitor container health automatically.

Changes:
- Added --health flag that validates configuration and plugin connectivity
- Implemented HealthCheck() method in pkg/poller/commands.go
- Updated Dockerfile with HEALTHCHECK instruction (30s interval, 10s timeout)
- Updated MANUAL.md with --health flag documentation
- Added health check documentation to Docker README
- Added comments to docker-compose examples about built-in health check

The health check:
- Validates configuration file is found and parseable
- Ensures at least one input and one enabled output are configured
- Performs basic validation on enabled outputs
- Returns exit code 0 (healthy) or 1 (unhealthy)
- Runs silently for Docker compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-08 13:09:10 -06:00

59 lines
2.0 KiB
YAML

# This is for unifi-poller v2.
version: '3'
services:
influxdb:
restart: always
image: influxdb:1.8
ports:
- '8086:8086'
volumes:
- influxdb-storage:/var/lib/influxdb
environment:
- INFLUXDB_DB=${INFLUXDB_DB}
- INFLUXDB_HTTP_AUTH_ENABLED=${INFLUXDB_HTTP_AUTH_ENABLED}
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_ADMIN_USER}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
# enable if using influxdb v2 instead
# - DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG}
# - DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET}
# - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_ADMIN_TOKEN}
grafana:
image: grafana/grafana:latest
restart: always
ports:
- '3000:3000'
volumes:
- grafana-storage:/var/lib/grafana
depends_on:
- influxdb
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
- GF_INSTALL_PLUGINS=grafana-clock-panel,natel-discrete-panel,grafana-piechart-panel
unifi-poller:
restart: always
image: ghcr.io/unpoller/unpoller:${POLLER_TAG}
# Health check is built into the Docker image
# It validates configuration and checks plugin connectivity
depends_on:
- grafana
- influxdb
environment:
- UP_INFLUXDB_DB=${INFLUXDB_DB}
- UP_INFLUXDB_USER=${INFLUXDB_ADMIN_USER}
- UP_INFLUXDB_PASS=${INFLUXDB_ADMIN_PASSWORD}
- UP_INFLUXDB_ORG=${INFLUXDB_ORG}
- UP_INFLUXDB_BUCKET=${INFLUXDB_BUCKET}
- UP_INFLUXDB_AUTH_TOKEN=${INFLUXDB_ADMIN_TOKEN}
- UP_INFLUXDB_URL=http://influxdb:8086
- UP_UNIFI_DEFAULT_USER=${UNIFI_USER}
- UP_UNIFI_DEFAULT_PASS=${UNIFI_PASS}
- UP_UNIFI_DEFAULT_URL=${UNIFI_URL}
- UP_POLLER_DEBUG=${POLLER_DEBUG}
- UP_UNIFI_DEFAULT_SAVE_DPI=${POLLER_SAVE_DPI}
- UP_PROMETHEUS_NAMESPACE=unpoller
volumes:
influxdb-storage:
grafana-storage: