Skip to content

Commit

Permalink
Fix docker builds for musl
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellrj committed Aug 11, 2018
1 parent 46ea9f0 commit 62abb79
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM amd64/busybox:musl
FROM alpine:latest
MAINTAINER Richard Mitchell <hue-exporter@mitch.org.uk>

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" ]
CMD [ "--config.file=/etc/hue_exporter/config.yml" ]
8 changes: 3 additions & 5 deletions Dockerfile.arm7
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM arm32v7/busybox:latest
FROM armhf/alpine:latest
MAINTAINER Richard Mitchell <hue-exporter@mitch.org.uk>

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" ]
CMD [ "--config.file=/etc/hue_exporter/config.yml" ]
File renamed without changes.
7 changes: 7 additions & 0 deletions Dockerfile.build.amd64.musl
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
9 changes: 9 additions & 0 deletions Dockerfile.build.arm7.musl
Original file line number Diff line number Diff line change
@@ -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
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
.PHONY: all style test format vet staticcheck build
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const VERSION = "0.2.0"
const VERSION = "0.2.1"

0 comments on commit 62abb79

Please # to comment.