From 9db929ed8b98e0974eb62d462079c8d1d5a0765c Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 4 Jan 2026 00:05:08 +0000 Subject: [PATCH] fix: remove hardcoded platform args causing wrong architecture builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: arm64 images were getting amd64 binaries causing "exec format error" when running on ARM platforms. Root cause: - Dockerfiles had ARG TARGETOS=linux and ARG TARGETARCH=amd64 - FROM --platform=$TARGETOS/$TARGETARCH used these defaults - buildx couldn't override them, so all builds used amd64 Solution: - Removed --platform from FROM statement - Let buildx automatically handle platform selection - Declared ARGs AFTER FROM to receive buildx values - buildx automatically sets TARGETPLATFORM, TARGETOS, TARGETARCH Now each platform builds native binaries: - linux/amd64 → amd64 binary - linux/arm64 → arm64 binary This fixes: exec /usr/local/bin/migrate: exec format error --- Dockerfile.migrate | 10 +++++++--- Dockerfile.scanner | 10 +++++++--- Dockerfile.server | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Dockerfile.migrate b/Dockerfile.migrate index dd14328..f761232 100644 --- a/Dockerfile.migrate +++ b/Dockerfile.migrate @@ -1,10 +1,14 @@ # Migration Engine - Database Migration Tool # Multi-stage build to compile with CGO support -ARG TARGETOS=linux -ARG TARGETARCH=amd64 # Build stage -FROM --platform=$TARGETOS/$TARGETARCH golang:1.25-alpine AS builder +# Let buildx handle platform automatically +FROM golang:1.25-alpine AS builder + +# Get build platform from buildx +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH # Install build dependencies for CGO RUN apk add --no-cache \ diff --git a/Dockerfile.scanner b/Dockerfile.scanner index bdb6f8d..c10a367 100644 --- a/Dockerfile.scanner +++ b/Dockerfile.scanner @@ -1,10 +1,14 @@ # Scanning Engine - Background Scanner Worker # Multi-stage build to compile with CGO support -ARG TARGETOS=linux -ARG TARGETARCH=amd64 # Build stage -FROM --platform=$TARGETOS/$TARGETARCH golang:1.25-alpine AS builder +# Let buildx handle platform automatically +FROM golang:1.25-alpine AS builder + +# Get build platform from buildx +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH # Install build dependencies for CGO RUN apk add --no-cache \ diff --git a/Dockerfile.server b/Dockerfile.server index cf02455..fdf6fdd 100644 --- a/Dockerfile.server +++ b/Dockerfile.server @@ -1,10 +1,14 @@ # Application Engine - GoHoarder Server # Multi-stage build to compile with CGO support -ARG TARGETOS=linux -ARG TARGETARCH=amd64 # Build stage -FROM --platform=$TARGETOS/$TARGETARCH golang:1.25-alpine AS builder +# Let buildx handle platform automatically +FROM golang:1.25-alpine AS builder + +# Get build platform from buildx +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH # Install build dependencies for CGO RUN apk add --no-cache \