File tree Expand file tree Collapse file tree 6 files changed +141
-5
lines changed Expand file tree Collapse file tree 6 files changed +141
-5
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - ' main'
7
+ tags :
8
+ - ' v*'
9
+ pull_request :
10
+ branches :
11
+ - ' main'
12
+ paths :
13
+ - ' Dockerfile'
14
+ - ' .dockerignore'
15
+
16
+ env :
17
+ REGISTRY : ghcr.io
18
+ IMAGE_NAME : ${{ github.repository }}
19
+
20
+ jobs :
21
+ docker :
22
+ runs-on : ubuntu-latest
23
+ steps :
24
+ - name : Checkout
25
+ uses : actions/checkout@v3
26
+
27
+ - name : Set up QEMU
28
+ uses : docker/setup-qemu-action@v2
29
+
30
+ - name : Set up Docker Buildx
31
+ uses : docker/setup-buildx-action@v2
32
+
33
+ - name : Docker meta
34
+ id : meta
35
+ uses : docker/metadata-action@v4
36
+ with :
37
+ images : |
38
+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39
+ tags : |
40
+ type=ref,event=branch
41
+ type=ref,event=pr
42
+ type=semver,pattern={{version}}
43
+ type=semver,pattern={{major}}.{{minor}}
44
+
45
+ - name : Login to Container Registry
46
+ if : github.event_name != 'pull_request'
47
+ uses : docker/login-action@v2
48
+ with :
49
+ registry : ${{ env.REGISTRY }}
50
+ username : ${{ github.actor }}
51
+ password : ${{ secrets.GITHUB_TOKEN }}
52
+
53
+ - name : Build and push
54
+ uses : docker/build-push-action@v4
55
+ with :
56
+ context : .
57
+ platforms : linux/amd64,linux/arm64
58
+ push : ${{ github.event_name != 'pull_request' }}
59
+ tags : ${{ steps.meta.outputs.tags }}
60
+ labels : ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change
1
+ name : go
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - v*
7
+ branches :
8
+ - master
9
+ - main
10
+ pull_request :
11
+
12
+ permissions :
13
+ contents : read
14
+ pull-requests : read
15
+
16
+ jobs :
17
+ test :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - uses : actions/checkout@v3
21
+ - uses : actions/setup-go@v3
22
+ with :
23
+ go-version : 1.21
24
+ - name : Test
25
+ run : go test -v ./...
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ name: goreleaser
3
3
on :
4
4
push :
5
5
tags :
6
- - ' *'
6
+ - ' v *'
7
7
8
8
permissions :
9
9
contents : write
Original file line number Diff line number Diff line change
1
+ name : lint
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ pull_request :
8
+
9
+ permissions :
10
+ contents : read
11
+
12
+ jobs :
13
+
14
+ golangci-lint :
15
+ name : golangci-lint
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - uses : actions/checkout@v3
19
+ - uses : actions/setup-go@v4
20
+ with :
21
+ go-version : ' 1.21'
22
+ cache : false
23
+ - name : golangci-lint
24
+ uses : golangci/golangci-lint-action@v3
25
+ with :
26
+ version : v1.53
27
+
28
+ conventional-commits :
29
+ name : conventional-commits
30
+ runs-on : ubuntu-latest
31
+ steps :
32
+ - uses : actions/checkout@v3
33
+ - uses : webiny/action-conventional-commits@v1.1.0
Original file line number Diff line number Diff line change
1
+ FROM golang:1.21-alpine AS build
2
+ WORKDIR /app
3
+ COPY go.mod go.sum ./
4
+ RUN go mod download -x
5
+ COPY . ./
6
+ RUN CGO_ENABLED=0 go build -trimpath -o /bin/ksei-exporter ./exporter
7
+ RUN CGO_ENABLED=0 go build -trimpath -o /bin/wei ./wei
8
+
9
+ FROM alpine:edge
10
+ RUN apk add -U curl ca-certificates && update-ca-certificates
11
+ COPY --from=build /bin/ksei-exporter /bin/ksei-exporter
12
+ COPY --from=build /bin/wei /bin/wei
13
+ CMD [ "/bin/ksei-exporter" ]
Original file line number Diff line number Diff line change @@ -16,14 +16,19 @@ import (
16
16
)
17
17
18
18
type Config struct {
19
- Bind string `envconfig:"bind" default:"0.0.0.0:8080"`
20
- Router struct {
19
+ BindHost string `envconfig:"bind_host" default:"0.0.0.0"`
20
+ BindPort int `envconfig:"bind_port" default:"8080"`
21
+ Router struct {
21
22
URL string `envconfig:"url"`
22
23
Username string `envconfig:"username"`
23
24
Password string `envconfig:"password"`
24
25
} `envconfig:"router"`
25
26
}
26
27
28
+ func (c * Config ) Bind () string {
29
+ return fmt .Sprintf ("%s:%d" , c .BindHost , c .BindPort )
30
+ }
31
+
27
32
func main () {
28
33
_ = godotenv .Overload (".env" )
29
34
@@ -53,12 +58,12 @@ func main() {
53
58
})))
54
59
55
60
log .Info ().
56
- Str ("bind" , cfg .Bind ).
61
+ Str ("bind" , cfg .Bind () ).
57
62
Str ("url" , cfg .Router .URL ).
58
63
Str ("user" , cfg .Router .Username ).
59
64
Msg ("starting metrics exporter server" )
60
65
61
- if err := e .Start (cfg .Bind ); err != nil {
66
+ if err := e .Start (cfg .Bind () ); err != nil {
62
67
fmt .Println ()
63
68
fmt .Println (err )
64
69
os .Exit (1 )
You can’t perform that action at this time.
0 commit comments