Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Arch Docker Builds when using Confluent Kafka Go #1374

Open
2 of 7 tasks
gwthm-in opened this issue Jan 5, 2025 · 2 comments
Open
2 of 7 tasks

Multi Arch Docker Builds when using Confluent Kafka Go #1374

gwthm-in opened this issue Jan 5, 2025 · 2 comments

Comments

@gwthm-in
Copy link

gwthm-in commented Jan 5, 2025

Description

Im trying to build multi arch docker images for one of the application which uses confluent-kafka-go 2.6 version. Are these supported at this moment? I have tried multiple variations, still no luck.

How to reproduce

  1. Building docker images in github actions.
FROM --platform=$BUILDPLATFORM golang:1.23.0-alpine AS base

# Install build dependencies
RUN apk add --no-cache bash alpine-sdk

# Build stage - Download dependencies and compile
FROM base AS builder

WORKDIR /app

# Build arguments for multi-arch support
ARG TARGETOS
ARG TARGETARCH

ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
ENV CGO_ENABLED=1

# Download dependencies with secret mount for git authentication
RUN --mount=type=secret,id=access_token \
    --mount=type=bind,target=.,source=. \
    go mod download && go mod verify

RUN mkdir -p /app/out/${TARGETARCH}

RUN --mount=type=bind,target=.,source=.,rw=true \
    make build BUILD_DIR=/app/out/${TARGETARCH}

# Final stage - Create the runtime image
FROM --platform=$TARGETPLATFORM alpine AS runner

WORKDIR /app

COPY --from=builder /app/out/${TARGETARCH}/sample-service /app/sample-service

EXPOSE 3000
ENTRYPOINT ["/app/sample-service"]

And my Makefile

.PHONY: setup lint build

SHELL := /bin/bash # Use bash syntax

BUILD_DIR ?= "out"
APP_EXECUTABLE := "$(BUILD_DIR)/sample-service"

GOPATH=$(shell go env GOPATH)
CGO_ENABLED=1
LDFLAGS="-X main.Version=`git rev-parse --short HEAD` -linkmode external -extldflags '-static'"

export GOPATH
export GOROOT
export GONOSUMDB
export CGO_ENABLED

build: ## Build the application
	mkdir -p $(BUILD_DIR)
	GO111MODULE=on go build -tags musl -ldflags $(LDFLAGS) -o $(APP_EXECUTABLE) cmd/*

This build fails with the following error:

#23 [linux/amd64->arm64 builder 4/4] RUN --mount=type=bind,target=.,source=.,rw=true     make build BUILD_DIR=/app/out/arm64
#23 0.112 mkdir -p /app/out/arm64
#23 0.120 GO111MODULE=on go build -tags musl -ldflags "-X main.Version=`git rev-parse --short HEAD` -linkmode external -extldflags '-static'" -o "/app/out/arm64/samiksha-service" cmd/*
#23 3.803 # runtime/cgo
#23 3.803 gcc_arm64.S: Assembler messages:
#23 3.803 gcc_arm64.S:30: Error: no such instruction: `stp x29,x30,[sp,'
#23 3.803 gcc_arm64.S:34: Error: operand size mismatch for `mov'
#23 3.803 gcc_arm64.S:36: Error: no such instruction: `stp x19,x20,[sp,'
#23 3.803 gcc_arm64.S:39: Error: no such instruction: `stp x21,x22,[sp,'
#23 3.803 gcc_arm64.S:42: Error: no such instruction: `stp x23,x24,[sp,'
#23 3.803 gcc_arm64.S:45: Error: no such instruction: `stp x25,x26,[sp,'
#23 3.803 gcc_arm64.S:48: Error: no such instruction: `stp x27,x28,[sp,'
#23 3.803 gcc_arm64.S:52: Error: operand size mismatch for `mov'
#23 3.803 gcc_arm64.S:53: Error: operand size mismatch for `mov'
#23 3.803 gcc_arm64.S:54: Error: operand size mismatch for `mov'
#23 3.803 gcc_arm64.S:56: Error: no such instruction: `blr x20'
#23 3.803 gcc_arm64.S:57: Error: no such instruction: `blr x19'
#23 3.803 gcc_arm64.S:59: Error: no such instruction: `ldp x27,x28,[sp,'
#23 3.803 gcc_arm64.S:62: Error: no such instruction: `ldp x25,x26,[sp,'
#23 3.803 gcc_arm64.S:65: Error: no such instruction: `ldp x23,x24,[sp,'
#23 3.803 gcc_arm64.S:68: Error: no such instruction: `ldp x21,x22,[sp,'
#23 3.803 gcc_arm64.S:71: Error: no such instruction: `ldp x19,x20,[sp,'
#23 3.803 gcc_arm64.S:74: Error: no such instruction: `ldp x29,x30,[sp],'
#23 ...

#24 [linux/amd64 builder 4/4] RUN --mount=type=bind,target=.,source=.,rw=true     make build BUILD_DIR=/app/out/amd64
#24 0.113 mkdir -p /app/out/amd64
#24 0.120 GO111MODULE=on go build -tags musl -ldflags "-X main.Version=`git rev-parse --short HEAD` -linkmode external -extldflags '-static'" -o "/app/out/amd64/samiksha-service" cmd/*
#24 ...

#23 [linux/amd64->arm64 builder 4/4] RUN --mount=type=bind,target=.,source=.,rw=true     make build BUILD_DIR=/app/out/arm64
#23 10.85 make: *** [Makefile:39: build] Error 1
#23 ERROR: process "/bin/sh -c make build BUILD_DIR=/app/out/${TARGETARCH}" did not complete successfully: exit code: 2

#24 [linux/amd64 builder 4/4] RUN --mount=type=bind,target=.,source=.,rw=true     make build BUILD_DIR=/app/out/amd64
#24 CANCELED
------
 > [linux/amd64->arm64 builder 4/4] RUN --mount=type=bind,target=.,source=.,rw=true     make build BUILD_DIR=/app/out/arm64:
3.803 gcc_arm64.S:54: Error: operand size mismatch for `mov'
3.803 gcc_arm64.S:56: Error: no such instruction: `blr x20'
3.803 gcc_arm64.S:57: Error: no such instruction: `blr x19'
3.803 gcc_arm64.S:59: Error: no such instruction: `ldp x27,x28,[sp,'
3.803 gcc_arm64.S:62: Error: no such instruction: `ldp x25,x26,[sp,'
3.803 gcc_arm64.S:65: Error: no such instruction: `ldp x23,x24,[sp,'
3.803 gcc_arm64.S:68: Error: no such instruction: `ldp x21,x22,[sp,'
3.803 gcc_arm64.S:71: Error: no such instruction: `ldp x19,x20,[sp,'
3.803 gcc_arm64.S:74: Error: no such instruction: `ldp x29,x30,[sp],'
10.85 make: *** [Makefile:39: build] Error 1

Checklist

Please provide the following information:

  • confluent-kafka-go and librdkafka version (LibraryVersion(2.6.1)):
  • Apache Kafka broker version:
  • Client configuration: ConfigMap{...}
  • Operating system:
  • Provide client logs (with "debug": ".." as necessary)
  • Provide broker log excerpts
  • Critical issue
@gwthm-in
Copy link
Author

gwthm-in commented Jan 6, 2025

@milindl I see that you are looking into the multi arch builds in another issue. Can you provide any insights here?

@gwthm-in
Copy link
Author

gwthm-in commented Jan 7, 2025

@edenhill Could you provide any pointers here to fix multi arch builds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant