diff --git a/.goreleaser.yml b/.goreleaser.yml index 80795ae..3108539 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,6 +16,44 @@ builds: - windows env: - CGO_ENABLED=0 +dockers: +- image_templates: + - 'ghcr.io/luzilla/{{.ProjectName}}:{{ .Tag }}-amd64' + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/amd64" + extra_files: + - rbls.ini + - targets.ini + goarch: amd64 +- image_templates: + - 'ghcr.io/luzilla/{{.ProjectName}}:{{ .Tag }}-arm64' + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.name={{.ProjectName}}" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--label=org.opencontainers.image.source={{.GitURL}}" + - "--platform=linux/arm64" + extra_files: + - rbls.ini + - targets.ini + goarch: arm64 +docker_manifests: +- name_template: ghcr.io/luzilla/{{.ProjectName}}:{{ .Tag }} + image_templates: + - ghcr.io/luzilla/{{.ProjectName}}:{{ .Tag }}-amd64 + - ghcr.io/luzilla/{{.ProjectName}}:{{ .Tag }}-arm64 archives: - files: - none* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7e434d0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3 + +ENV DNSBL_EXP_RESOLVER=ubound:53 +ENV DNSBL_EXP_RBLS=/etc/dnsbl-exporter/rbls.ini +ENV DNSBL_EXP_TARGETS=/etc/dnsbl-exporter/targets.ini + +COPY dnsbl-exporter /usr/bin/ + +RUN mkdir -p /etc/dnsbl-exporter +COPY rbls.ini /etc/dnsbl-exporter/ +COPY targets.ini /etc/dnsbl-exporter/ + +EXPOSE 9211 + +ENTRYPOINT ["/usr/bin/dnsbl-exporter"] diff --git a/Makefile b/Makefile index 9171572..cfda49b 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ GO_VERSION:=1.16 build: goreleaser build --snapshot --single-target --rm-dist +.PHONY: snapshot +snapshot: + goreleaser build --snapshot --rm-dist + .PHONY: test test: docker run \ diff --git a/README.md b/README.md index 5f6489c..5d121d7 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,43 @@ $ dnsbl-exporter -h Go to http://127.0.0.1:9211/ in your browser. -#### Quering +#### Container + +Docker/OCI images are available in the [container registry](/~https://github.com/orgs/Luzilla/packages?repo_name=dnsbl_exporter): + +```sh +$ docker pull ghcr.io/luzilla/dnsbl_exporter:vX.Y.Z +... +``` + +Please note: `latest` is not provided. + +The images expect `target.ini` and `rbls.ini` in the following location: + +```sh +/etc/dnsbl-exporter +``` + +Either start the container and supply the contents, or build your own image: + +```sh +docker run \ + --rm \ + -e DNSBL_EXP_RESOLVER=your.resolver:53 \ + -p 9211:9211 \ + -v ./conf:/etc/dnsbl-exporter \ + ghcr.io/luzilla/dnsbl_exporter:vA.B.C +``` + +```docker +FROM ghcr.io/luzilla/dnsbl_exporter:vA.B.C + +ADD my-target.ini /etc/dnsbl-exporter/target.ini +ADD my-rbls.ini /etc/dnsbl-exporter/rbls.ini +``` + + +#### Querying The individual configured servers and their status are represented by a **gauge**: diff --git a/app/app.go b/app/app.go index 0407aba..5a6c3b3 100644 --- a/app/app.go +++ b/app/app.go @@ -30,24 +30,28 @@ func NewApp(name string, version string) DNSBLApp { app.Version = version app.Flags = []cli.Flag{ cli.StringFlag{ - Name: "config.dns-resolver", - Value: "127.0.0.1:53", - Usage: "IP address[:port] of the resolver to use.", + Name: "config.dns-resolver", + Value: "127.0.0.1:53", + Usage: "IP address[:port] of the resolver to use.", + EnvVar: "DNSBL_EXP_RESOLVER", }, cli.StringFlag{ - Name: "config.rbls", - Value: "./rbls.ini", - Usage: "Configuration file which contains RBLs", + Name: "config.rbls", + Value: "./rbls.ini", + Usage: "Configuration file which contains RBLs", + EnvVar: "DNSBL_EXP_RBLS", }, cli.StringFlag{ - Name: "config.targets", - Value: "./targets.ini", - Usage: "Configuration file which contains the targets to check.", + Name: "config.targets", + Value: "./targets.ini", + Usage: "Configuration file which contains the targets to check.", + EnvVar: "DNSBL_EXP_TARGETS", }, cli.StringFlag{ - Name: "web.listen-address", - Value: ":9211", - Usage: "Address to listen on for web interface and telemetry.", + Name: "web.listen-address", + Value: ":9211", + Usage: "Address to listen on for web interface and telemetry.", + EnvVar: "DNSBL_EXP_LISTEN", }, cli.StringFlag{ Name: "web.telemetry-path",