Skip to content

Commit

Permalink
Docker: Support pre-installing plugins from other sources in custom D…
Browse files Browse the repository at this point in the history
…ockerfiles (grafana#31234)

Update custom Dockerfiles to support pre-installing plugins from other sources.

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
  • Loading branch information
2 people authored and ryantxu committed Mar 30, 2021
1 parent 93b93d7 commit 39f0db2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
15 changes: 14 additions & 1 deletion docs/sources/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ docker build \
docker run -d -p 3000:3000 --name=grafana grafana-custom
```

### Build with pre-installed plugins from other sources

You can build a Docker image with plugins from other sources by specifying the URL like this: `GF_INSTALL_PLUGINS=<url to plugin zip>;<plugin name>`.

```bash
cd packaging/docker/custom
docker build \
--build-arg "GRAFANA_VERSION=latest" \
--build-arg "GF_INSTALL_PLUGINS=http://plugin-domain.com/my-custom-plugin.zip;custom-plugin,grafana-clock-panel" \
-t grafana-custom -f Dockerfile .

docker run -d -p 3000:3000 --name=grafana grafana-custom
```

Replace `Dockerfile` in above example with `ubuntu.Dockerfile` to build a custom Ubuntu based image (Grafana v6.5+).

### Build with Grafana Image Renderer plugin pre-installed
Expand Down Expand Up @@ -227,4 +241,3 @@ Refer to [Configure a Grafana Docker image]({{< relref "../administration/config

Refer to the [Configuration]({{< relref "../administration/configuration.md" >}}) page for details on options for customizing your environment, logging, database, and so on.


12 changes: 9 additions & 3 deletions packaging/docker/custom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ ARG GF_INSTALL_PLUGINS=""

RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \
OLDIFS=$IFS; \
IFS=','; \
IFS=','; \
for plugin in ${GF_INSTALL_PLUGINS}; do \
IFS=$OLDIFS; \
grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \
done; \
if expr match "$plugin" '.*\;.*'; then \
pluginUrl=$(echo "$plugin" | cut -d';' -f 1); \
pluginWithoutUrl=$(echo "$plugin" | cut -d';' -f 2); \
grafana-cli --pluginUrl "${pluginUrl}" --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${pluginWithoutUrl}; \
else \
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}; \
fi \
done \
fi
12 changes: 9 additions & 3 deletions packaging/docker/custom/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ ARG GF_INSTALL_PLUGINS=""

RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \
OLDIFS=$IFS; \
IFS=','; \
IFS=','; \
for plugin in ${GF_INSTALL_PLUGINS}; do \
IFS=$OLDIFS; \
grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \
done; \
if expr match "$plugin" '.*\;.*'; then \
pluginUrl=$(echo "$plugin" | cut -d';' -f 1); \
pluginWithoutUrl=$(echo "$plugin" | cut -d';' -f 2); \
grafana-cli --pluginUrl "${pluginUrl}" --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${pluginWithoutUrl}; \
else \
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}; \
fi \
done \
fi

0 comments on commit 39f0db2

Please sign in to comment.