From 39cf10dee6846cdd8bb9ed4c78a78a349d217c6b Mon Sep 17 00:00:00 2001 From: kwall Date: Fri, 24 Nov 2023 15:20:00 +0000 Subject: [PATCH 1/2] Simple Dockerfile for kaf. Signed-off-by: kwall --- Dockerfile | 23 +++++++++++++++++++++++ Makefile | 9 +++++++++ 2 files changed, 32 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1f1e7599 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.18 as BuildStage + +# Set destination for COPY +WORKDIR /app + +# Download Go modules +COPY go.mod go.sum ./ +RUN go mod download +COPY . ./ + +# Build +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-w -s" -o /kaf ./cmd/kaf + +FROM scratch + +WORKDIR / + +COPY --from=BuildStage /kaf /bin/kaf + +USER 1001 + +# Run +CMD ["/bin/kaf"] diff --git a/Makefile b/Makefile index 6ff869f1..de78fa71 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,10 @@ +DOCKER_CMD ?= docker +DOCKER_REGISTRY ?= docker.io +DOCKER_ORG ?= $(USER) +DOCKER_NAME ?= kaf +DOCKER_TAG ?= latest +BUILD_TAG ?= latest + build: go build -ldflags "-w -s" ./cmd/kaf install: @@ -6,3 +13,5 @@ release: goreleaser --rm-dist run-kafka: docker-compose up -d +docker-build: + ${DOCKER_CMD} build -t ${DOCKER_REGISTRY}/${DOCKER_ORG}/${DOCKER_NAME}:${DOCKER_TAG} . From 6c60f4131e76ff91ea575d5b4896e29458adf333 Mon Sep 17 00:00:00 2001 From: kwall Date: Mon, 19 Feb 2024 09:00:12 +0000 Subject: [PATCH 2/2] use go 1.22 for builder stage Signed-off-by: kwall --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1f1e7599..1daaae78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18 as BuildStage +FROM golang:1.22 as BuildStage # Set destination for COPY WORKDIR /app