Skip to main content

Deployment & Configuration

This page details how to deploy the monitoring stack and configure the vision services to export metrics correctly.

πŸ“‹ Prerequisites​

  • Docker & Docker Compose
  • NVIDIA Drivers and NVIDIA Container Toolkit (for GPU metrics).

πŸ›  Docker Composition​

The monitoring stack typically runs in its own docker-compose.yml to decouple it from the main application life-cycle. Ideally, it joins a shared network (e.g., monitor-net) to reach the application containers.

Service Configuration​

Ensure your docker-compose.yml mounts the following volumes for persistence and configuration:

services:
prometheus:
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus

grafana:
volumes:
- grafana-data:/var/lib/grafana
- ./provisioning:/etc/grafana/provisioning
- ./dashboards:/var/lib/grafana/dashboards

Note: We use Grafana Provisioning to automatically load dashboards from files on startup, treating them as Infrastructure-as-Code.

πŸ”Œ Enabling GPU Acceleration & Metrics​

To support hardware acceleration (h264_cuvid) AND export metrics, the camera-manager service requires a specific build strategy to avoid conflicts between ultralytics and the custom CUDA-compiled OpenCV.

The "Requirements Trick"​

The ultralytics package automatically installs a standard CPU-only opencv-python, which overwrites our custom GPU build. To fix this, use the following Dockerfile pattern:

# 1. Copy dependencies
COPY requirements.cuda.txt .

# 2. Install deps AND immediately uninstall the CPU-opencv
RUN pip install --no-cache-dir -r requirements.cuda.txt && \
pip uninstall -y opencv-python opencv-python-headless || true

# 3. Ensure Environment Variables point to the system libraries
ENV PYTHONPATH=/app:/usr/local/lib/python3.11/site-packages
ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}

This forces Python to fall back to the system-level OpenCV in /usr/local/lib/, which fully supports NVIDIA CUDA.

βš™οΈ Environment Variables​

The Monitoring Stack uses the following Dokploy/Env variables:

VariableDescription
GF_SERVER_ROOT_URLPublic URL for Grafana (e.g. https://monitor.firstbreath.fr).
GF_AUTH_GITHUB_CLIENT_IDFor OAuth Login.
GF_AUTH_GITHUB_ALLOWED_ORGANIZATIONSRestrict login to the FirstBreath org.

πŸ”„ Provisioning Flow​

  1. Datasources: Defined in provisioning/datasources/datasource.yml. Configures Prometheus URL automatically.
  2. Dashboards: Defined in provisioning/dashboards/dashboard.yml. Loads JSON files from /var/lib/grafana/dashboards.

Important: Set allowUiUpdates: false in dashboard.yml to prevent the database from caching old dashboard versions, ensuring the JSON files on disk are always the source of truth.