Skip to content

Unofficial Grafonnet dockerfile and image for local and CI pipeline builds.

License

Notifications You must be signed in to change notification settings

corentinaltepe/grafonnet-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

grafonnet-docker

Unofficial Grafonnet dockerfile and image for local and CI pipeline builds. Inspired by AndrewFarley/grafonnet-lib-dockerhub.

This image is fit for local builds, Gitlab CI, Azure DevOps CI and probably more.

Source code here.

Registries and Tags

Docker images are published to DockerHub and GitHub registries.

Tags follow Grafonnet releases. Find available tags here and here.

How To

Local Builds

To build a mysourcefile.jsonnet file into a mysourcefile.json dasbhoard for Grafana.

On Windows, do a cd to your source file:

docker run --rm -v %~dp0:/here corentinaltepe/grafonnet:latest jsonnet /here/mysourcefile.jsonnet >> %~dp0mysourcefile.json

On Linux, do a cd to your source file:

docker run --rm -v $(pwd):/here corentinaltepe/grafonnet:latest jsonnet /here/mysourcefile.jsonnet >> $(pwd)/mysourcefile.json

Automatically Build and Load to Grafana

The following script builds a file for Grafana's API and then pushes it to Grafana. It is written for Windows. Replace %~dp0 with $(pwd) for Linux.

::: Build the dashboard *.jsonnet to *.json
echo { "dashboard": > %~dp0mysourcefile.json
docker run --rm -v %~dp0:/here corentinaltepe/grafonnet:latest jsonnet /here/myfile.jsonnet >> %~dp0mysourcefile.json
echo , "overwrite": true} >> %~dp0mysourcefile.json

::: Load to Grafana
::: Replace admin:admin with your credentials or add authentication bearer in HTTP headers
curl -X POST -H "Content-Type: application/json" -d @%~dp0mysourcefile.json "http://admin:admin@localhost:3000/api/dashboards/db"

CI Jobs

Azure DevOps

- job: Build_Grafana_Dashboards
  container:
    image: corentinaltepe/grafonnet:0.1.0
  pool:
    vmImage: "ubuntu-latest"
  steps:
    # Build every .jsonnet file into a .json dashboard 
    # and place them in grafonnet-out/ directory
    - script: >
        mkdir grafonnet-out

        for file in dashboards/*.jsonnet ; do 
          name=$(basename $file)
          jsonnet $file > grafonnet-out/grafana.${name%.jsonnet}.json
        done

About

Unofficial Grafonnet dockerfile and image for local and CI pipeline builds.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published