fix: remove hardcoded platform args causing wrong architecture builds

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
This commit is contained in:
2026-01-04 00:05:08 +00:00
parent 0a2c5f6c2c
commit 9db929ed8b
3 changed files with 21 additions and 9 deletions
+7 -3
View File
@@ -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 \