Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile and instructions for building and running. #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/



9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down