Skip to content

feat: add GF_SERVER_ROOT_URL to Grafana service in generated docker-compose #415

@josecelano

Description

@josecelano

Problem

When the deployer generates a docker-compose.yml, the Grafana service does not include
GF_SERVER_ROOT_URL. Without it, Grafana defaults to http://localhost:3000 when
generating public dashboard share URLs, making them unreachable externally.

For example, sharing the Tracker Overview dashboard on the Torrust Tracker Demo produced:

http://localhost:3000/public-dashboards/186b355b56cd482d9c441a0affdb8ecd

instead of the correct:

https://grafana.torrust-tracker-demo.com/public-dashboards/186b355b56cd482d9c441a0affdb8ecd

See the Grafana documentation:
Externally shared dashboards

Fix

Follow the existing environment variable injection pattern already used for other
Grafana settings — value in .env, reference in docker-compose.yml.

docker-compose.yml template

grafana:
  environment:
    - GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER}
    - GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
    - GF_SERVER_ROOT_URL=${GF_SERVER_ROOT_URL}

.env template

# Grafana server root URL — used to generate correct public dashboard share links
GF_SERVER_ROOT_URL='https://<grafana-domain>'

The <grafana-domain> value should be derived from the same deployer input that
already defines the Grafana virtual host in the Caddyfile (e.g. grafana.torrust-tracker-demo.com).

Reference

This was discovered and manually patched on the Torrust Tracker Demo:
torrust/torrust-tracker-demo#9

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions