Refactor PR build workflow to target arm64 for Darwin binaries and remove obsolete cross-compilation Dockerfiles

This commit is contained in:
Cédric Verstraeten
2025-09-12 12:23:00 +02:00
parent b4cf49d4be
commit e715575f20
3 changed files with 3 additions and 120 deletions

View File

@@ -74,12 +74,12 @@ jobs:
path: agent-${{matrix.architecture}}.tar
build-darwin:
runs-on: ubuntu-24.04
runs-on: ubuntu-24.04-arm
permissions:
contents: write
strategy:
matrix:
architecture: [amd64, arm64]
architecture: [arm64]
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
@@ -96,9 +96,8 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Build Darwin binary with Docker
run: |
docker build -f Dockerfile.cross \
docker build -f Dockerfile.arm64 \
--build-arg GOOS=darwin \
--build-arg GOARCH=${{matrix.architecture}} \
-t darwin-${{matrix.architecture}} .
CID=$(docker create darwin-${{matrix.architecture}})
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}

View File

@@ -1,55 +0,0 @@
# Multi-platform build Dockerfile with GOOS/GOARCH arguments
ARG GOOS=linux
ARG GOARCH=amd64
ARG BASE_IMAGE_VERSION=amd64-ddbe40e
# Use golang official image for cross-compilation
FROM golang:1.24-alpine AS build-machinery
LABEL AUTHOR=uug.ai
ARG GOOS
ARG GOARCH
ENV CGO_ENABLED=0
ENV GOOS=${GOOS}
ENV GOARCH=${GOARCH}
ENV GOSUMDB=off
##########################################
# Installing some additional dependencies.
RUN apk add --no-cache git build-base
##############################################################################
# Copy all the relevant source code in the Docker image, so we can build this.
WORKDIR /go/src/github.com/kerberos-io/agent
COPY machinery ./machinery
RUN rm -rf ./machinery/.env
##################################################################
# Get the latest commit hash, so we know which version we're running
COPY .git ./.git
RUN cd .git && git log --format="%H" -n 1 | head -c7 > ../machinery/version
RUN cat ./machinery/version
##################
# Build Machinery
RUN cd machinery && \
go mod download && \
go build -tags timetzdata,netgo,osusergo --ldflags '-s -w' -o agent main.go && \
mkdir -p /agent && \
mv agent /agent/ && \
mv version /agent/ && \
cp -r data /agent/ && \
mkdir -p /agent/data/cloud && \
mkdir -p /agent/data/snapshots && \
mkdir -p /agent/data/log && \
mkdir -p /agent/data/recordings && \
mkdir -p /agent/data/capture-test && \
mkdir -p /agent/data/config
# Final stage - minimal runtime
FROM scratch
COPY --from=build-machinery /agent /home/agent

View File

@@ -1,61 +0,0 @@
# Alternative: Modify existing Dockerfile to support cross-compilation
ARG BASE_IMAGE_VERSION=amd64-ddbe40e
ARG GOOS=linux
ARG GOARCH=amd64
FROM kerberos/base:${BASE_IMAGE_VERSION} AS build-machinery
LABEL AUTHOR=uug.ai
ARG GOOS
ARG GOARCH
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:/usr/local/lib:$PATH
ENV GOSUMDB=off
ENV GOOS=${GOOS}
ENV GOARCH=${GOARCH}
# For cross-compilation, disable CGO when building for different platforms
# Enable CGO only for native linux builds
ENV CGO_ENABLED=0
##########################################
# Installing some additional dependencies.
RUN apt-get upgrade -y && apt-get update && apt-get install -y --fix-missing --no-install-recommends \
git build-essential cmake pkg-config unzip libgtk2.0-dev \
curl ca-certificates libcurl4-openssl-dev libssl-dev libjpeg62-turbo-dev && \
rm -rf /var/lib/apt/lists/*
##############################################################################
# Copy all the relevant source code in the Docker image, so we can build this.
RUN mkdir -p /go/src/github.com/kerberos-io/agent
COPY machinery /go/src/github.com/kerberos-io/agent/machinery
RUN rm -rf /go/src/github.com/kerberos-io/agent/machinery/.env
##################################################################
# Get the latest commit hash, so we know which version we're running
COPY .git /go/src/github.com/kerberos-io/agent/.git
RUN cd /go/src/github.com/kerberos-io/agent/.git && git log --format="%H" -n 1 | head -c7 > /go/src/github.com/kerberos-io/agent/machinery/version
RUN cat /go/src/github.com/kerberos-io/agent/machinery/version
##################
# Build Machinery
RUN cd /go/src/github.com/kerberos-io/agent/machinery && \
go mod download && \
go build -tags timetzdata,netgo,osusergo --ldflags '-s -w' -o main main.go && \
mkdir -p /agent && \
mv main /agent && \
mv version /agent && \
mv data /agent && \
mkdir -p /agent/data/cloud && \
mkdir -p /agent/data/snapshots && \
mkdir -p /agent/data/log && \
mkdir -p /agent/data/recordings && \
mkdir -p /agent/data/capture-test && \
mkdir -p /agent/data/config
# Continue with the rest of your existing Dockerfile...