From 62abb79e43ecbd88ec3b44df4aea5bd9df3a3bbc Mon Sep 17 00:00:00 2001 From: Richard Mitchell Date: Sat, 11 Aug 2018 20:45:31 +0100 Subject: [PATCH] Fix docker builds for musl --- CHANGELOG.md | 4 ++++ Dockerfile.amd64 | 8 +++----- Dockerfile.arm7 | 8 +++----- ...e.build.amd64 => Dockerfile.build.amd64.glibc | 0 Dockerfile.build.amd64.musl | 7 +++++++ ...ile.build.arm7 => Dockerfile.build.arm7.glibc | 0 Dockerfile.build.arm7.musl | 9 +++++++++ Makefile | 16 ++++++++++++---- README.md | 10 +++++++--- version.go | 2 +- 10 files changed, 46 insertions(+), 18 deletions(-) rename Dockerfile.build.amd64 => Dockerfile.build.amd64.glibc (100%) create mode 100644 Dockerfile.build.amd64.musl rename Dockerfile.build.arm7 => Dockerfile.build.arm7.glibc (100%) create mode 100644 Dockerfile.build.arm7.musl diff --git a/CHANGELOG.md b/CHANGELOG.md index 507b130..10b837b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.2.1 (2018-08-11) + +Use musl builds for alpine images. + # v0.2.0 (2018-08-10) * Corrected 'on' value for lights diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index a5e4c2a..019f2a5 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -1,11 +1,9 @@ -FROM amd64/busybox:musl +FROM alpine:latest MAINTAINER Richard Mitchell -COPY ./build/hue_exporter.amd64 /bin/hue_exporter +COPY ./build/hue_exporter.amd64.musl /bin/hue_exporter COPY hue_exporter.example.yml /etc/hue_exporter/config.yml -VOLUME /etc/hue_exporter - EXPOSE 9366 ENTRYPOINT [ "/bin/hue_exporter" ] -CMD [ "--config.file=/etc/hue_exporter/config.yml" ] \ No newline at end of file +CMD [ "--config.file=/etc/hue_exporter/config.yml" ] diff --git a/Dockerfile.arm7 b/Dockerfile.arm7 index 515b735..e7379c8 100644 --- a/Dockerfile.arm7 +++ b/Dockerfile.arm7 @@ -1,11 +1,9 @@ -FROM arm32v7/busybox:latest +FROM armhf/alpine:latest MAINTAINER Richard Mitchell -COPY ./build/hue_exporter.arm7 /bin/hue_exporter +COPY ./build/hue_exporter.arm7.musl /bin/hue_exporter COPY hue_exporter.example.yml /etc/hue_exporter/config.yml -VOLUME /etc/hue_exporter - EXPOSE 9366 ENTRYPOINT [ "/bin/hue_exporter" ] -CMD [ "--config.file=/etc/hue_exporter/config.yml" ] \ No newline at end of file +CMD [ "--config.file=/etc/hue_exporter/config.yml" ] diff --git a/Dockerfile.build.amd64 b/Dockerfile.build.amd64.glibc similarity index 100% rename from Dockerfile.build.amd64 rename to Dockerfile.build.amd64.glibc diff --git a/Dockerfile.build.amd64.musl b/Dockerfile.build.amd64.musl new file mode 100644 index 0000000..ae41e33 --- /dev/null +++ b/Dockerfile.build.amd64.musl @@ -0,0 +1,7 @@ +FROM amd64/golang:alpine + +COPY . /go/src/github.com/mitchellrj/hue_exporter +WORKDIR /go/src/github.com/mitchellrj/hue_exporter + +VOLUME /build +CMD go build -o /build/hue_exporter.amd64.musl diff --git a/Dockerfile.build.arm7 b/Dockerfile.build.arm7.glibc similarity index 100% rename from Dockerfile.build.arm7 rename to Dockerfile.build.arm7.glibc diff --git a/Dockerfile.build.arm7.musl b/Dockerfile.build.arm7.musl new file mode 100644 index 0000000..be51123 --- /dev/null +++ b/Dockerfile.build.arm7.musl @@ -0,0 +1,9 @@ +FROM armhf/alpine:latest + +RUN apk add --no-cache git go musl-dev && mkdir /go +ENV GOPATH=/go +COPY . /go/src/github.com/mitchellrj/hue_exporter +WORKDIR /go/src/github.com/mitchellrj/hue_exporter + +VOLUME /build +CMD go build -o /build/hue_exporter.arm7.musl diff --git a/Makefile b/Makefile index f80bc56..6338f07 100644 --- a/Makefile +++ b/Makefile @@ -18,19 +18,27 @@ staticcheck: build: go build -dist: darwin amd64 arm7 docker +dist: darwin amd64 arm7 amd64-musl arm7-musl docker darwin: cp hue_exporter build/hue_exporter.darwin amd64: - docker build --pull -f Dockerfile.build.amd64 -t hue_exporter_builder:latest . + docker build --pull -f Dockerfile.build.amd64.glibc -t hue_exporter_builder:latest . docker run -v $$(pwd)/build:/build hue_exporter_builder:latest arm7: - docker build --pull -f Dockerfile.build.arm7 -t hue_exporter_builder:latest-arm . + docker build --pull -f Dockerfile.build.arm7.glibc -t hue_exporter_builder:latest-arm . docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-arm +amd64-musl: + docker build --pull -f Dockerfile.build.amd64.musl -t hue_exporter_builder:latest-musl . + docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-musl + +arm7-musl: + docker build --pull -f Dockerfile.build.arm7.musl -t hue_exporter_builder:latest-arm-musl . + docker run -v $$(pwd)/build:/build hue_exporter_builder:latest-arm-musl + docker: docker build --pull -f Dockerfile.amd64 -t mitchellrj/hue_exporter:latest . docker tag mitchellrj/hue_exporter:latest mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V) @@ -43,4 +51,4 @@ push: docker push mitchellrj/hue_exporter:latest-arm7 docker push mitchellrj/hue_exporter:$$(build/hue_exporter.darwin -V)-arm7 -.PHONY: all style test format vet staticcheck build \ No newline at end of file +.PHONY: all style test format vet staticcheck build diff --git a/README.md b/README.md index 34c5e97..f72bda5 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Each light metric is labelled with the friendly name, the model, the type, the p * `hue_light_hue` * `hue_light_saturation` * `hue_light_on`: `0` means off, `1` means on -* `hue_light_reachable`: `0` or `1` representing false or true +* `hue_light_reachable`: `0` or `1` representing false or true ## Group metrics @@ -38,8 +38,8 @@ Each sensor metric is labelled with the friendly name, the model, the type, the * `hue_sensor_value`: value varies depending on the `type` of the sensor. For switches, it's the value of the last button pressed; for daylight and presence sensors it's a `0` or `1` representing false or true values; for the temperature sensor it's hundredths of a degree celsius; for the light level sensor it's Lux. * `hue_sensor_battery`: battery level percentage (0 for sensors that have no battery) * `hue_sensor_last_updated`: last updated timestamp (Unix epoch) -* `hue_sensor_on`: `0` or `1` representing false or true -* `hue_sensor_reachable`: `0` or `1` representing false or true +* `hue_sensor_on`: `0` or `1` representing false or true +* `hue_sensor_reachable`: `0` or `1` representing false or true Some sensor type values you might find useful: @@ -73,6 +73,10 @@ Those flag values are the defaults, so you could just run `hue_exporter` on its There are a few docker images built, including ones for ARM7 (Raspberry Pi). You can find these on [Docker Hub](https://hub.docker.com/r/mitchellrj/hue_exporter). They expose `/etc/hue_exporter` as a volume for you to generate or pass in your own configuration. +``` +docker run -p 9366:9366 -v my_config.yml:/etc/hue_exporter/config.yml mitchellrj/hue_exporter:latest +``` + ## License MIT / X11 Consortium license. I'd prefer to use Apache 2.0, but the excellent Hue library that this app uses is GPL 2.0 and that isn't compatible with Apache. diff --git a/version.go b/version.go index 9077aa4..0f69e55 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package main -const VERSION = "0.2.0" +const VERSION = "0.2.1"