Fix Grafana provisioning: bake datasource/dashboard config into custom image

Coolify only copies docker-compose.yaml and .env to its working directory —
the ./grafana/provisioning bind mount source was always empty on the server,
so Grafana started with no datasource or dashboard configured (causing the
'Failed to load home dashboard' error).

Fix: build a custom Grafana image (grafana/Dockerfile) that COPYs the
provisioning directory at image build time. Grafana substitutes
${GRAFANA_DB_RO_PASSWORD} at startup from the env var now in Coolify's store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
David Kiania 2026-04-11 22:18:44 +03:00
parent d706d17cc8
commit fcc745f09d
2 changed files with 9 additions and 2 deletions

View file

@ -55,7 +55,9 @@ services:
retries: 3 retries: 3
grafana: grafana:
image: grafana/grafana:11.0.0 build:
context: ./grafana
dockerfile: Dockerfile
restart: always restart: always
depends_on: depends_on:
timescale_db: timescale_db:
@ -67,7 +69,7 @@ services:
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards-json/noc_fleet_dashboard.json - GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards-json/noc_fleet_dashboard.json
volumes: volumes:
- grafana-data:/var/lib/grafana - grafana-data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning:ro # Provisioning is baked into the image via grafana/Dockerfile — no bind mount needed.
# COOLIFY DOMAIN LOGIC: # COOLIFY DOMAIN LOGIC:
# You will set the actual URL in the Coolify UI, # You will set the actual URL in the Coolify UI,
# but the service needs to expose port 3000 internally. # but the service needs to expose port 3000 internally.

5
grafana/Dockerfile Normal file
View file

@ -0,0 +1,5 @@
FROM grafana/grafana:11.0.0
# Bake provisioning files into the image so Coolify bind mounts are not needed.
# Grafana substitutes ${ENV_VAR} references in provisioning files at startup.
COPY provisioning /etc/grafana/provisioning