add periodic docker container build
This commit is contained in:
parent
3f531e59fc
commit
fe2ddc088e
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "apcupsd-exporter",
|
||||
"image": "golang:1.19",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"golang.go"
|
||||
]
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "go install honnef.co/go/tools/cmd/staticcheck@latest"
|
||||
}
|
|
@ -13,19 +13,19 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go-version: [1.17]
|
||||
go-version: [1.19]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run tests
|
||||
run: go test -race ./...
|
||||
run: cd src && go test -race ./...
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
name: Release Docker
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "00 01 * * 0"
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/apcupsd-exporter
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
file: docker/Dockerfile
|
||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
@ -12,18 +12,18 @@ jobs:
|
|||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.17]
|
||||
go-version: [1.19]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install staticcheck
|
||||
run: go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||
|
@ -32,7 +32,7 @@ jobs:
|
|||
run: staticcheck -version
|
||||
|
||||
- name: Run staticcheck
|
||||
run: staticcheck ./...
|
||||
|
||||
- name: Run go vet
|
||||
run: go vet ./...
|
||||
run: |
|
||||
cd src
|
||||
staticcheck ./...
|
||||
go vet ./...
|
||||
|
|
24
README.md
24
README.md
|
@ -1,14 +1,32 @@
|
|||
# apcupsd_exporter [![Linux Test Status](https://github.com/mdlayher/apcupsd_exporter/workflows/Linux%20Test/badge.svg)](https://github.com/mdlayher/apcupsd_exporter/actions) [![GoDoc](http://godoc.org/github.com/mdlayher/apcupsd_exporter?status.svg)](http://godoc.org/github.com/mdlayher/apcupsd_exporter)
|
||||
# apcupsd_exporter [![Linux Test Status](https://github.com/bossm8/apcupsd_exporter/workflows/Linux%20Test/badge.svg)](https://github.com/bossm8/apcupsd_exporter/actions) [![GoDoc](http://godoc.org/github.com/mdlayher/apcupsd_exporter?status.svg)](http://godoc.org/github.com/mdlayher/apcupsd_exporter)
|
||||
|
||||
## Notes
|
||||
|
||||
This is a fork of the original repository from [mdlayher](https://github.com/mdlayher/apcupsd_exporter) with an added docker built.
|
||||
|
||||
## Docker Usage
|
||||
|
||||
Per default the docker container runs `--help` start the apcupsd_exporter like this (e.g.)
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
-it --rm -p 9162:9162 \
|
||||
--add-host host.docker.internal:host-gateway \
|
||||
ghcr.io/bossm8/apcupsd-exporter:latest -apcupsd.addr host.docker.internal:3551
|
||||
```
|
||||
|
||||
|
||||
## Original README
|
||||
|
||||
Command `apcupsd_exporter` provides a Prometheus exporter for the
|
||||
[apcupsd](http://www.apcupsd.org/) Network Information Server (NIS). MIT
|
||||
Licensed.
|
||||
|
||||
## Usage
|
||||
### Usage
|
||||
|
||||
Available flags for `apcupsd_exporter` include:
|
||||
|
||||
```
|
||||
```bash
|
||||
$ ./apcupsd_exporter -h
|
||||
Usage of ./apcupsd_exporter:
|
||||
-apcupsd.addr string
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
FROM golang:latest
|
||||
|
||||
COPY ./src /src
|
||||
WORKDIR /src
|
||||
|
||||
RUN go install && \
|
||||
CGO_ENABLED=0 go build -o apcups-exporter cmd/apcupsd_exporter/main.go && \
|
||||
chmod +x apcups-exporter
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
COPY --from=0 /src/apcups-exporter /usr/sbin/apcups-exporter
|
||||
|
||||
RUN adduser -s /bin/sh -H -D apcexp
|
||||
|
||||
USER apcexp
|
||||
|
||||
ENTRYPOINT ["apcups-exporter"]
|
||||
CMD ["--help"]
|
|
@ -1,7 +1,7 @@
|
|||
package apcupsdexporter
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
@ -27,7 +27,7 @@ func testCollector(t *testing.T, collector prometheus.Collector) []byte {
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read server response: %v", err)
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
module github.com/mdlayher/apcupsd_exporter
|
||||
|
||||
go 1.17
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/mdlayher/apcupsd v0.0.0-20220314153302-72ccd80310d1
|
Loading…
Reference in New Issue