File tree Expand file tree Collapse file tree 5 files changed +46
-23
lines changed Expand file tree Collapse file tree 5 files changed +46
-23
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,17 @@ jobs:
1414 steps :
1515 - name : Checkout
1616 uses : actions/checkout@v3
17+ - name : Get git describe
18+ id : get-version
19+ run : |
20+ describe=$(git describe --tags --always --dirty)
21+ echo "GIT_COMMIT_REF_NAME=$describe" >> $GITHUB_ENV
1722 - name : Setup go
1823 uses : actions/setup-go@v4
1924 with :
2025 go-version : ' 1.20'
2126 check-latest : true
2227 - run : go version
23- - name : Run build and test
24- run : make clean build test
2528 - name : Docker meta
2629 id : meta
2730 uses : docker/metadata-action@v4
@@ -64,19 +67,19 @@ jobs:
6467 with :
6568 context : .
6669 push : true
67- build-args : |
68- MAKE_TARGET=test build
70+ platforms : linux/amd64,linux/arm64
6971 tags : ${{ steps.meta.outputs.tags }}
7072 labels : ${{ steps.meta.outputs.labels }}
73+ build-args : VERSION=${{ env.GIT_COMMIT_REF_NAME }}
7174 - name : Docker build and push - all
7275 uses : docker/build-push-action@v4
7376 with :
7477 context : .
7578 push : true
76- build-args : |
77- MAKE_TARGET=all
79+ platforms : linux/amd64,linux/arm64
7880 tags : ${{ steps.meta-all.outputs.tags }}
7981 labels : ${{ steps.meta-all.outputs.labels }}
82+ build-args : VERSION=${{ env.GIT_COMMIT_REF_NAME }}
8083 - name : Run GoReleaser
8184 uses : goreleaser/goreleaser-action@v4
8285 if : startsWith(github.ref, 'refs/tags/')
Original file line number Diff line number Diff line change 11builds :
22- binary : kafka-proxy
3+ env :
4+ - CGO_ENABLED=0
35 goos :
46 - windows
57 - darwin
68 - linux
79 goarch :
810 - amd64
11+ - arm64
12+ ignore :
13+ - goos : windows
14+ goarch : arm64
915 ldflags : -s -w -X github.com/grepplabs/kafka-proxy/config.Version={{.Version}}
1016archives :
1117 - name_template : " {{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
Original file line number Diff line number Diff line change 1- FROM golang:1.20-alpine3.17 as builder
1+ FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.17 as builder
22RUN apk add alpine-sdk ca-certificates
33
4+ ARG TARGETOS
5+ ARG TARGETARCH
6+ ARG TARGETVARIANT
7+ ARG VERSION
8+
9+ ENV CGO_ENABLED=0 \
10+ GO111MODULE=on \
11+ GOOS=${TARGETOS} \
12+ GOARCH=${TARGETARCH} \
13+ GOARM=${TARGETVARIANT} \
14+ LDFLAGS="-X github.com/grepplabs/kafka-proxy/config.Version=${VERSION} -w -s"
15+
416WORKDIR /go/src/github.com/grepplabs/kafka-proxy
517COPY . .
618
7- ARG MAKE_TARGET= build
8- ARG GOOS=linux
9- ARG GOARCH=amd64
10- RUN make -e GOARCH=${GOARCH} -e GOOS=${GOOS} clean ${MAKE_TARGET}
19+ RUN mkdir -p build && \
20+ export GOARM=$( echo "${GOARM}" | cut -c2-) && \
21+ go build -mod=vendor -o build/kafka-proxy \
22+ -ldflags "${LDFLAGS}" .
1123
12- FROM alpine:3.17
24+ FROM --platform=$BUILDPLATFORM alpine:3.17
1325RUN apk add --no-cache ca-certificates
1426RUN adduser \
1527 --disabled-password \
Original file line number Diff line number Diff line change @@ -10,10 +10,11 @@ VERSION ?= $(shell git describe --tags --always --dirty)
1010GOPKGS = $(shell go list ./... | grep -v /vendor/)
1111BUILD_FLAGS ?=
1212LDFLAGS ?= -X github.com/grepplabs/kafka-proxy/config.Version=$(VERSION ) -w -s
13- TAG ?= "v0.3.5"
14- GOARCH ?= amd64
15- GOOS ?= linux
16-
13+ TAG ?= "v0.3.6"
14+ GOOS ?= $(if $(TARGETOS ) ,$(TARGETOS ) ,linux)
15+ GOARCH ?= $(if $(TARGETARCH ) ,$(TARGETARCH ) ,amd64)
16+ GOARM ?= $(TARGETVARIANT )
17+ BUILDPLATFORM ?= $(GOOS ) /$(GOARCH )
1718
1819PROTOC_GO_VERSION ?= v1.30
1920PROTOC_GRPC_VERSION ?= v1.2
@@ -41,15 +42,16 @@ build: build/$(BINARY)
4142
4243.PHONY : build/$(BINARY )
4344build/$(BINARY ) : $(SOURCES )
44- GOOS=$(GOOS ) GOARCH=$(GOARCH ) CGO_ENABLED=0 go build -mod=vendor -o build/$(BINARY ) $(BUILD_FLAGS ) -ldflags " $( LDFLAGS) " .
45+ GOOS=$(GOOS ) GOARCH=$(GOARCH ) GOARM=$(GOARM ) CGO_ENABLED=0 go build -mod=vendor -o build/$(BINARY ) $(BUILD_FLAGS ) -ldflags " $( LDFLAGS) " .
46+
47+ docker.build :
48+ docker buildx build --build-arg BUILDPLATFORM=$(BUILDPLATFORM ) --build-arg TARGETARCH=$(GOARCH ) -t local/kafka-proxy .
4549
4650tag :
4751 git tag $(TAG )
4852
4953release : clean
5054 git push origin $(TAG )
51- rm -rf $(ROOT_DIR ) /dist
52- curl -sL https://git.io/goreleaser | bash
5355
5456protoc.plugin.install :
5557 go install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GO_VERSION )
Original file line number Diff line number Diff line change @@ -47,11 +47,11 @@ As not every Kafka release adds new messages/versions which are relevant to the
4747
4848 Linux
4949
50- curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.3.5 /kafka-proxy-v0.3.5 -linux-amd64.tar.gz | tar xz
50+ curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.3.6 /kafka-proxy-v0.3.6 -linux-amd64.tar.gz | tar xz
5151
5252 macOS
5353
54- curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.3.5 /kafka-proxy-v0.3.5 -darwin-amd64.tar.gz | tar xz
54+ curl -Ls https://github.com/grepplabs/kafka-proxy/releases/download/v0.3.6 /kafka-proxy-v0.3.6 -darwin-amd64.tar.gz | tar xz
5555
56562 . Move the binary in to your PATH.
5757
@@ -69,7 +69,7 @@ Docker images are available on [Docker Hub](https://hub.docker.com/r/grepplabs/k
6969
7070You can launch a kafka-proxy container for trying it out with
7171
72- docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:v0.3.5 \
72+ docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:v0.3.6 \
7373 server \
7474 --bootstrap-server-mapping "localhost:19092,0.0.0.0:30001" \
7575 --bootstrap-server-mapping "localhost:29092,0.0.0.0:30002" \
@@ -88,7 +88,7 @@ Docker images with precompiled plugins located in `/opt/kafka-proxy/bin/` are ta
8888
8989You can launch a kafka-proxy container with auth-ldap plugin for trying it out with
9090
91- docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:v0.3.5 -all \
91+ docker run --rm -p 30001-30003:30001-30003 grepplabs/kafka-proxy:v0.3.6 -all \
9292 server \
9393 --bootstrap-server-mapping "localhost:19092,0.0.0.0:30001" \
9494 --bootstrap-server-mapping "localhost:29092,0.0.0.0:30002" \
You can’t perform that action at this time.
0 commit comments