grafana / grafonnet-lib

Jsonnet library for generating Grafana dashboard files.
https://grafana.github.io/grafonnet-lib/
Apache License 2.0
1.08k stars 217 forks source link

Build Grafonnet with Docker: add documentation #266

Open corentinaltepe opened 4 years ago

corentinaltepe commented 4 years ago

Hi, my team works on a Windows / .NET / C# stack. It was difficult to introduce a Go / Jsonnet / Grafonnet stack on Windows to build dashboards. I personnally tried to use the pip (and brew) packages, but they appeared to be incompatible with Windows. Works well with WSL2, but that's yet another thing to learn before building Grafana dashboards.

I ended up making a Docker image for the team to use in their local dev environment and in CI.

I was wondering if that'd be okay to add a section in the Getting Started and/or Usage documentation named Build with Docker (or equivalent)? If so, I'd be happy to submit a PR. Any suggestion or requirement on how to format this documentation?

beerfranz commented 3 years ago

Hello!

It's not a complete solution, but this is how I did:

Build

Clone the git repo: git clone https://github.com/grafana/grafonnet-lib.git

Create a dockerfile with this content:

FROM bitnami/jsonnet:0.17.0-debian-10-r173
WORKDIR /home
COPY ./grafonnet-lib/grafonnet /opt/bitnami/jsonnet/bin/grafonnet
USER nobody

Build the docker image: docker build -t grafonnet:local .

Run Go into the directory with your jsonnets.

In your jsonnet, import the lib: local grafana = import '/opt/bitnami/jsonnet/bin/grafonnet/grafana.libsonnet';

Run: docker run --rm -v $PWD:/home grafonnet:local prometheus.jsonnet