diff --git a/.gitignore b/.gitignore index 6bce343..20caf56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -search-api +vendor bin tmp .vscode diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..03c118f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:alpine as builder + +WORKDIR /go/src/github.com/eko/pihole-exporter +COPY . . + +RUN apk update && \ + apk --no-cache add git alpine-sdk + +RUN GO111MODULE=on go mod vendor +RUN GOOS=linux go build -o binary ./ + +FROM alpine + +LABEL name="pihole-exporter" + +WORKDIR /root/ +COPY --from=builder /go/src/github.com/eko/pihole-exporter/binary pihole-exporter + +CMD ["./pihole-exporter"] diff --git a/README.md b/README.md index 8ecd4e5..ac0afae 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,15 @@ You can download the latest version of the binary built for your architecture he [Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-arm) ] +### Using Docker + +The exporter is also available as a [Docker image](https://hub.docker.com/r/ekofr/pihole-exporter). +You can run it using the following example and pass configuration environment variables: + +``` +$ docker run -e 'PIHOLE_HOSTNAME=192.168.1.2' ekofr/pihole-exporter:latest +``` + ### From sources Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way: @@ -43,6 +52,12 @@ $ go get -u github.com/eko/pihole-exporter $ git clone https://github.com/eko/pihole-exporter.git ``` +Install the needed vendors: + +``` +$ GO111MODULE=on go mod vendor +``` + Then, build the binary (here, an example to run on Raspberry PI ARM architecture): ```bash $ GOOS=linux GOARCH=arm GOARM=7 go build -o pihole_exporter .