- create a new NodeJs application linked to a fork of this repo
- in your application environment variables add
GF_SERVER_HTTP_PORT=8080
,GOPATH=/home/bas/<app_id>/go_home
where <app_id> is the id of your application on clever cloud (found in the top right corner of the console) andGRAFANA_VERSION=v6.6.0
(or any other tag in the official Grafana repo) - you can now build and start the application, be aware however that if you restart it your data will not be persisted (see next section to learn how to persist data)
For this example we will use mysql however the procedure shouldn't be too different with any other type of database
- create your database add-on on clever cloud and link it to the application
- in your application environment variables you should now see the info you need to connect to your db
- you now need to link these informations to grafana. to do this you need to create a few environment variables (replace what's in '<>' with the actual value):
GF_DATABASE_NAME=<MYSQL_ADDON_DB>
GF_DATABASE_HOST=<MYSQL_ADDON_HOST>
GF_DATABASE_PASSWORD=<MYSQL_ADDON_PASSWORD>
GF_DATABASE_URL=<MYSQL_ADDON_URI>
GF_DATABASE_USER=<MYSQL_ADDON_USER>
GF_DATABASE_TYPE=mysql
- for more information on how to change grafana configuration through environment variables please check: http://docs.grafana.org/installation/configuration/
- create a new repo with a package.json with at least:
{ "name" : "<name-of-your-app>", "version" : "<version>", "scripts" : { "install" : "./build.sh", "start" : "./run.sh" }, "engines": { "node" : "^10" } }
- then create both scripts, the install one will build grafana and the start one will start the grafana-server binary
- in the install script put:
#!/bin/bash go get github.com/grafana/grafana cd $GOPATH/src/github.com/grafana/grafana go run build.go setup go run build.go build yarn install --pure-lockfile yarn dev
- this will build both the back-end and the front-end of Grafana.
- add
GOPATH=/home/bas/<app_id>/go_home
in your environment variables where <app_id> is the id of the app on clever-cloud - in the start script put:
#!/bin/bash cd $GOPATH/src/github.com/grafana/grafana $GOPATH/bin/grafana-server
- finally add
GF_SERVER_HTTP_PORT=8080
in your app environment variables to ensure Grafana starts on the correct port and make sure you have enabled a dedicated build instance - Grafana is now ready to start however at this point if you restart the app, all data will be lost as it's not persisted in a database
For this example we will be adding warp10 as a plugin to Grafana
- in your build script, add the following lines:
this will ensure the plugins directory is created and the plugins are correctly downloaded inside
mkdir -p data/plugins cd data/plugins git clone https://github.com/ovh/ovh-warp10-datasource.git
- restart your application, you should now see warp10 available as a plugin