From 86548eb444b18b49c22e8fb603ce59fbff09ea9e Mon Sep 17 00:00:00 2001 From: carolosfoscolos Date: Sun, 14 Aug 2022 22:49:22 +0100 Subject: [PATCH] Add Dockerfile and instructions for building and running. --- Dockerfile | 43 +++++++++++++++++++++++++++++++++++++++++++ README.md | 9 +++++++++ 2 files changed, 52 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be6a6d3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:20.04 as builder +ENV DEBIAN_FRONTEND=noninteractive +RUN apt update && \ + apt -y install gnupg curl + +# Install nodejs +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \ + apt update && \ + apt -y install nodejs && \ + node --version + +# Install yarn globally with npm (installs a yarn compatible with the node version we are using) +RUN npm install -g yarn + +# Install golang +RUN apt -y install golang && \ + mkdir -p /go && \ + go version + +# Set GOPATH +ENV GOPATH=/go +ENV PATH=$PATH:$GOPATH/bin + +# Install mage +RUN apt -y install git && \ + go get -u -d github.com/magefile/mage && \ + cd $GOPATH/src/github.com/magefile/mage && \ + go run bootstrap.go && \ + mage -version + +COPY ./ /opt/grafana-plugins/mqtt-datasource +WORKDIR /opt/grafana-plugins/mqtt-datasource + +# Install grafana toolikit on different RUNs so that we avoid unecessary downloads +RUN yarn add @grafana/toolkit --network-timeout 100000 +RUN yarn build +RUN yarn install + +FROM grafana/grafana:8.5.10-ubuntu +COPY --from=builder /opt/grafana-plugins/mqtt-datasource/dist /var/lib/grafana/plugins/mqtt-datasource/ + + + diff --git a/README.md b/README.md index eeae745..3365875 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,15 @@ Details: [Ubuntu](https://github.com/grafana/mqtt-datasource/issues/15#issuecomm This plugin currently supports MQTT v3.1.x. __Note: Since this plugin uses the Grafana Live Streaming API, make sure to use Grafana v8.0+__ +### Docker Build and Run + +`docker buildx build --platform=linux/amd64 -t grafana-mqtt-datasource .` + +`docker run -it -p 3000:3000 -e GF_DEFAULT_APP_MODE=development --name grafana-mqtt grafana-mqtt-datasource` + +It is also possible to copy the plugin outside of the running grafana container above with: +`docker cp grafana-mqtt:/var/lib/grafana/plugins/mqtt-datasource/ ./mqtt-plugin` + ### Installation Steps 1. Clone the plugin to your Grafana plugins directory.