From 7b8e50170efd931a5e75ef43ac8082df686e443a Mon Sep 17 00:00:00 2001 From: M Samuel Vijaykumar Date: Tue, 17 Jun 2025 12:52:53 +0530 Subject: [PATCH 1/2] chore: add devcontainer and VSCode configuration for Kafka development setup --- .devcontainer/devcontainer.env | 2 + .devcontainer/devcontainer.json | 16 +++++++ .devcontainer/docker-compose.yml | 73 ++++++++++++++++++++++++++++++++ .vscode/launch.json | 28 ++++++++++++ .vscode/tasks.json | 27 ++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 .devcontainer/devcontainer.env create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/devcontainer.env b/.devcontainer/devcontainer.env new file mode 100644 index 00000000..be2bd134 --- /dev/null +++ b/.devcontainer/devcontainer.env @@ -0,0 +1,2 @@ +KAFKA_BROKERS=kafka1:9092,kafka2:9093,kafka3:9094 +ZOOKEEPER=zookeeper:2181 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..74361a5b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "Kafka Proxy DevContainer", + "dockerComposeFile": [ + "docker-compose.yml" + ], + "service": "dev", + "workspaceFolder": "/workspace", + "extensions": [ + "golang.Go", + "ms-azuretools.vscode-docker" + ], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "postCreateCommand": "go mod tidy" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..5b1f4b76 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,73 @@ +version: '3.8' +services: + zookeeper: + image: confluentinc/cp-zookeeper:7.5.0 + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ZOOKEEPER_TICK_TIME: 2000 + ports: + - "2181:2181" + kafka1: + image: confluentinc/cp-kafka:7.5.0 + depends_on: + - zookeeper + ports: + - "9092:9092" + environment: + KAFKA_BROKER_ID: 1 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9092,PLAINTEXT_HOST://localhost:19092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3 + extra_hosts: + - "host.docker.internal:host-gateway" + kafka2: + image: confluentinc/cp-kafka:7.5.0 + depends_on: + - zookeeper + ports: + - "9093:9093" + environment: + KAFKA_BROKER_ID: 2 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9093,PLAINTEXT_HOST://localhost:19093 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3 + extra_hosts: + - "host.docker.internal:host-gateway" + kafka3: + image: confluentinc/cp-kafka:7.5.0 + depends_on: + - zookeeper + ports: + - "9094:9094" + environment: + KAFKA_BROKER_ID: 3 + KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka3:9094,PLAINTEXT_HOST://localhost:19094 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 + KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 2 + KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 3 + extra_hosts: + - "host.docker.internal:host-gateway" + dev: + image: mcr.microsoft.com/devcontainers/go:1.22 + volumes: + - ..:/workspace:cached + command: sleep infinity + depends_on: + - kafka1 + - kafka2 + - kafka3 + environment: + - KAFKA_BROKERS=kafka1:9092,kafka2:9093,kafka3:9094 + working_dir: /workspace + network_mode: service:zookeeper diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..3b3b11a5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Kafka Proxy Server", + "type": "go", + "request": "launch", + "mode": "auto", + "preLaunchTask": "Start Kafka DevContainer", + "postDebugTask": "Stop Kafka DevContainer", + "program": "${workspaceFolder}", + "env": { + "KAFKA_BROKERS": "kafka1:9092,kafka2:9093,kafka3:9094", + "ZOOKEEPER": "zookeeper:2181" + }, + "args": [ + "server", + "--bootstrap-server-mapping", "kafka1:9092,0.0.0.0:30001", + "--bootstrap-server-mapping", "kafka2:9093,0.0.0.0:30002", + "--bootstrap-server-mapping", "kafka3:9094,0.0.0.0:30003", + "--debug-enable" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..679fcb70 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Start Kafka DevContainer", + "type": "shell", + "command": "docker compose -f ${workspaceFolder}/.devcontainer/docker-compose.yml up -d", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Stop Kafka DevContainer", + "type": "shell", + "command": "docker compose -f ${workspaceFolder}/.devcontainer/docker-compose.yml down", + "presentation": { + "reveal": "always", + "panel": "new" + } + } + ] +} From 4ad29f657fb9d391baa9c135c3108e4928153c58 Mon Sep 17 00:00:00 2001 From: M Samuel Vijaykumar Date: Tue, 17 Jun 2025 12:55:10 +0530 Subject: [PATCH 2/2] feat: add multi-architecture Docker build support for amd64 and arm64 --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 85caa2bc..c6d40061 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ GOPKGS = $(shell go list ./... | grep -v /vendor/) BUILD_FLAGS ?= LDFLAGS ?= -X github.com/grepplabs/kafka-proxy/config.Version=$(VERSION) -w -s TAG ?= "v0.4.3" +REPO ?= "grepplabs/kafka-proxy" PROTOC_GO_VERSION ?= v1.33 PROTOC_GRPC_VERSION ?= v1.2 @@ -55,6 +56,14 @@ docker.build: docker.build.all: docker build --build-arg VERSION=$(VERSION) -t local/kafka-proxy -f Dockerfile.all . +docker.build.multiarch: + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --push \ + --build-arg VERSION=$(VERSION) \ + -t $(REPO):$(TAG) \ + . + tag: git tag $(TAG)