Skip to content

Commit 8d4d51d

Browse files
authored
Use actual build process (#80)
* Use actual build process Signed-off-by: John Seekins <[email protected]> * Actually add missing files Signed-off-by: John Seekins <[email protected]> * fix build pattern Signed-off-by: John Seekins <[email protected]> * update deps and fix docker build Signed-off-by: John Seekins <[email protected]> * fix dockerfile (pass 2) Signed-off-by: John Seekins <[email protected]> * ignore all possible patterns of binary name Signed-off-by: John Seekins <[email protected]> * fix up build some more, functioning dockerfile Signed-off-by: John Seekins <[email protected]> * bump deps more Signed-off-by: John Seekins <[email protected]>
1 parent 8dd9d28 commit 8d4d51d

File tree

1,464 files changed

+547585
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,464 files changed

+547585
-90
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14-
/prometheus-kafka-adapter
14+
prometheus-kafka-adapter-libc
15+
prometheus-kafka-adapter-musl
16+
prometheus-kafka-adapter

Dockerfile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
FROM golang:1.16.3-buster as build
2-
1+
FROM golang:1.17.3-alpine as build
32
WORKDIR /src/prometheus-kafka-adapter
43

5-
COPY go.mod .
6-
COPY go.sum .
7-
RUN go mod download
4+
COPY go.mod go.sum vendor *.go ./
85

96
ADD . /src/prometheus-kafka-adapter
107

11-
RUN go build -o /prometheus-kafka-adapter -ldflags '-w -extldflags "-static"'
12-
RUN go test ./...
8+
RUN apk add --no-cache gcc musl-dev
9+
RUN go build -ldflags='-w -s -extldflags "-static"' -tags musl,static,netgo -mod=vendor -o /prometheus-kafka-adapter
1310

14-
FROM alpine:3.13
11+
FROM alpine:3.14
1512

1613
COPY schemas/metric.avsc /schemas/metric.avsc
1714
COPY --from=build /prometheus-kafka-adapter /

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
NAME := prometheus-kafka-adapter
2+
PACKAGE_NAME := github.com/Telefonica/prometheus-kafka-adapter
3+
GO_VER := 1.17.5
4+
LIBC_GO_VER := $(GO_VER)-buster
5+
MUSL_GO_VER := $(GO_VER)-alpine
6+
7+
all: fmt test build
8+
9+
fmt:
10+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) gofmt -l -w -s *.go
11+
12+
test:
13+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) sh tools/testscript.sh vet
14+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) sh tools/testscript.sh test
15+
16+
build: build-libc build-musl
17+
18+
build-libc:
19+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(LIBC_GO_VER) sh tools/buildscript.sh $(NAME)
20+
21+
build-musl:
22+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) sh tools/buildscript.sh $(NAME)
23+
24+
vendor-update:
25+
rm -rf go.mod go.sum vendor/
26+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) go mod init $(PACKAGE_NAME)
27+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) go mod tidy
28+
docker run --rm -v $(CURDIR):/app:z -w /app golang:$(MUSL_GO_VER) apk add --no-cache gcc musl-dev && go mod vendor
29+
30+
clean:
31+
rm -f $(NAME)-libc $(NAME)-musl

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ When deployed in a Kubernetes cluster using Helm and using an external Prometheu
7878

7979
## development
8080

81-
```
82-
go test
83-
go build
84-
```
81+
The provided Makefile can do basic linting/building for you simply:
82+
83+
* `make fmt` -> basic formatting.
84+
* `make test` -> runs `go test` fixtures
85+
* `make vet` -> runs `go vet` against the package
86+
* `make vendor-update` -> ensure dependencies are up to date
87+
* `make` -> builds libc and musl based binaries, including testing and vetting code
8588

8689
## contributing
8790

go.mod

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,49 @@
11
module github.com/Telefonica/prometheus-kafka-adapter
22

3+
go 1.17
4+
35
require (
4-
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
5-
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
6-
github.com/beorn7/perks v1.0.1 // indirect
7-
github.com/confluentinc/confluent-kafka-go v1.6.1
8-
github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607
9-
github.com/gin-gonic/gin v1.6.3
10-
github.com/gogo/protobuf v1.3.1
11-
github.com/golang/snappy v0.0.1
12-
github.com/grpc-ecosystem/grpc-gateway v1.5.0 // indirect
6+
github.com/confluentinc/confluent-kafka-go v1.8.2
7+
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19
8+
github.com/gin-gonic/gin v1.7.7
9+
github.com/gogo/protobuf v1.3.2
10+
github.com/golang/snappy v0.0.4
1311
github.com/linkedin/goavro v2.1.0+incompatible
14-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
15-
github.com/prometheus/client_golang v0.8.0
12+
github.com/prometheus/client_golang v1.11.0
1613
github.com/prometheus/client_model v0.2.0
17-
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e
18-
github.com/prometheus/procfs v0.1.3 // indirect
19-
github.com/prometheus/prometheus v2.4.2+incompatible
20-
github.com/sirupsen/logrus v1.6.0
21-
github.com/stretchr/testify v1.6.1
22-
google.golang.org/genproto v0.0.0-20180928223349-c7e5094acea1 // indirect
23-
google.golang.org/grpc v1.15.0 // indirect
24-
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
25-
gopkg.in/linkedin/goavro.v1 v1.0.5 // indirect
26-
gopkg.in/yaml.v2 v2.2.8
14+
github.com/prometheus/common v0.32.1
15+
github.com/prometheus/prometheus v2.5.0+incompatible
16+
github.com/sirupsen/logrus v1.8.1
17+
github.com/stretchr/testify v1.7.0
18+
gopkg.in/yaml.v2 v2.4.0
2719
)
2820

29-
go 1.13
21+
require (
22+
github.com/beorn7/perks v1.0.1 // indirect
23+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
24+
github.com/davecgh/go-spew v1.1.1 // indirect
25+
github.com/gin-contrib/sse v0.1.0 // indirect
26+
github.com/go-playground/locales v0.13.0 // indirect
27+
github.com/go-playground/universal-translator v0.17.0 // indirect
28+
github.com/go-playground/validator/v10 v10.4.1 // indirect
29+
github.com/golang/protobuf v1.4.3 // indirect
30+
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
31+
github.com/json-iterator/go v1.1.11 // indirect
32+
github.com/leodido/go-urn v1.2.0 // indirect
33+
github.com/mattn/go-isatty v0.0.12 // indirect
34+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
35+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36+
github.com/modern-go/reflect2 v1.0.1 // indirect
37+
github.com/pmezard/go-difflib v1.0.0 // indirect
38+
github.com/prometheus/procfs v0.6.0 // indirect
39+
github.com/ugorji/go/codec v1.1.7 // indirect
40+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
41+
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
42+
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
43+
golang.org/x/text v0.3.6 // indirect
44+
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987 // indirect
45+
google.golang.org/grpc v1.33.1 // indirect
46+
google.golang.org/protobuf v1.26.0-rc.1 // indirect
47+
gopkg.in/linkedin/goavro.v1 v1.0.5 // indirect
48+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
49+
)

0 commit comments

Comments
 (0)