diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..fe27350 --- /dev/null +++ b/Containerfile @@ -0,0 +1,18 @@ +FROM docker.io/golang:alpine AS builder + +WORKDIR /usr/local/src/exporter +COPY --chown=nobody:nogroup . . +RUN apk --no-cache add --update make && make build + +FROM docker.io/alpine:latest + +RUN addgroup -S icinga_exporter && \ + adduser -S icinga_exporter -G icinga_exporter && \ + apk --no-cache add --update ca-certificates + +COPY --from=builder /usr/local/src/exporter/dist/icinga2-exporter /usr/sbin/icinga2-exporter + +USER icinga_exporter +ENTRYPOINT ["/usr/sbin/icinga2-exporter"] + +EXPOSE 9665 diff --git a/Makefile b/Makefile index 56d1b95..e303b2b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ COMMIT := $(shell git rev-parse HEAD) VERSION?=latest -DATE := $(shell date --iso-8601) +DATE := $(shell date -I) GOARCH?=amd64 GOOS?=linux @@ -20,5 +20,7 @@ test: coverage: go test -v -cover -coverprofile=coverage.out ./... &&\ go tool cover -html=coverage.out -o coverage.html +container: + podman build -t icinga-exporter:latest . clean: rm -f dist/* diff --git a/README.md b/README.md index f05495d..d5e9ed3 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,12 @@ The tables below list all existing collectors. | Collector | Flag | | ------------- | ---------- | | APIListener | `-collector.apilistener` | + +# Development + +Running tests: + +``` +make test +make coverage +```