grafana/grafana-docker

Supporting easy bundling of plugins into the Grafana image

xlson opened this issue · 2 comments

xlson commented

Background

The Grafana docker image supports installing plugins on the fly when it boots which is enough for most users. But if you are running an instance behind a firewall or without internet access that won't work. In this case its neccessary to build a new docker image that bundles the plugins.

Solutions

1. Extending the main Dockerfile

This would make it possible to specify plugins using docker build --build-arg "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource" . at build time.

# Add this in the main Dockerfile for Grafana
ARG GF_INSTALL_PLUGINS=""

RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \
    OLDIFS=$IFS; \
        IFS=','; \
    for plugin in ${GF_INSTALL_PLUGINS}; do \
        IFS=$OLDIFS; \
        grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \
    done; \
fi

Pros:

  • It's all in the same place

Cons:

  • requires forking/cloning the official repo and keeping updated with our revisions for updates to use
  • extra functionality in the Dockerfile that most users don't use

2. Creating an example Dockerfile

We could modify option 1 to fit into an example and stick it in examples/.

Pros:

  • a separation from the main file for a feature that few are likely to use
  • could be easily copy pasted without forking
  • switching version in FROM grafana/grafana:xxx would get any updates to our main container

Cons:

  • may be a bit harder to find

3. Putting a solution in the docs

Pros:

  • docs is the easiest place to find it

Cons:

  • may confuse users that are looking for instructions for installing plugins at boot and find this instead
  • extending our image is a little bit of an advanced use case, not sure we even want that in the docs
xlson commented

@DanCech Talked a bit with @bergquist yesterday and now I'm leaning towards option 2 again so I created this issue for us (and anyone else who has opinions) to discuss it.

I think 2 makes the most sense, as far as it being hard to find we'd still have the docs section and it would be able to link to the file for the user to download vs having to copy-paste from the docs themselves.

That Dockerfile can also have ARG GF_VERSION=latest so the user can build whatever grafana version they like via build args.

https://docs.docker.com/engine/reference/builder/#from