Added docker image

This commit is contained in:
Vincent Composieux 2019-05-26 10:49:58 +02:00
parent 69f5ce122f
commit c87fd560c5
No known key found for this signature in database
GPG Key ID: 7306974ABA6382AC
3 changed files with 35 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
search-api
vendor
bin
tmp
.vscode

19
Dockerfile Normal file
View File

@ -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"]

View File

@ -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 .