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:
| Variable | Description |
|---|---|
GF_SERVER_ROOT_URL | Public URL for Grafana (e.g. https://monitor.firstbreath.fr). |
GF_AUTH_GITHUB_CLIENT_ID | For OAuth Login. |
GF_AUTH_GITHUB_ALLOWED_ORGANIZATIONS | Restrict login to the FirstBreath org. |
π Provisioning Flowβ
- Datasources: Defined in
provisioning/datasources/datasource.yml. Configures Prometheus URL automatically. - Dashboards: Defined in
provisioning/dashboards/dashboard.yml. Loads JSON files from/var/lib/grafana/dashboards.
Important: Set
allowUiUpdates: falseindashboard.ymlto prevent the database from caching old dashboard versions, ensuring the JSON files on disk are always the source of truth.