From 2ea5dd4b54bf57c6d9d82c7bfef5e8dc769c4862 Mon Sep 17 00:00:00 2001 From: Carsten Date: Wed, 22 Apr 2026 08:27:25 +0200 Subject: [PATCH] feat(agent): docker-based cross-compile for linux binaries --- agent/Dockerfile.build | 32 ++++++++++++++++++++++++++++++++ agent/scripts/build-linux.sh | 17 +++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 agent/Dockerfile.build create mode 100755 agent/scripts/build-linux.sh diff --git a/agent/Dockerfile.build b/agent/Dockerfile.build new file mode 100644 index 0000000..3dbbb6c --- /dev/null +++ b/agent/Dockerfile.build @@ -0,0 +1,32 @@ +# Reproducible Burrito build environment for the agent. +# Produces linux_amd64 + linux_arm64 binaries into /work/agent/burrito_out. +# Keep elixir/OTP in sync with what the project compiles against locally +# (see `elixir --version` — currently Elixir 1.19 on OTP 28). +FROM elixir:1.19-otp-28 AS build + +ENV MIX_ENV=prod DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential git ca-certificates curl xz-utils unzip 7zip \ + && rm -rf /var/lib/apt/lists/* + +# Zig (Burrito needs it for cross-compile) +ARG ZIG_VERSION=0.13.0 +RUN curl -fsSL https://ziglang.org/download/${ZIG_VERSION}/zig-linux-$(uname -m)-${ZIG_VERSION}.tar.xz \ + | tar -xJ -C /opt && ln -s /opt/zig-linux-*/zig /usr/local/bin/zig + +WORKDIR /work/agent +RUN mix local.hex --force && mix local.rebar --force + +# Copy sources last for layer caching +COPY mix.exs mix.lock ./ +RUN mix deps.get --only prod + +COPY lib lib +COPY config config + +RUN mix deps.compile +RUN mix release + +# Default: print the produced artifacts +CMD ["sh", "-c", "ls -la burrito_out/"] diff --git a/agent/scripts/build-linux.sh b/agent/scripts/build-linux.sh new file mode 100755 index 0000000..7f795c4 --- /dev/null +++ b/agent/scripts/build-linux.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Produce Linux Burrito binaries for the agent. +# Usage: ./scripts/build-linux.sh [output_dir] +set -euo pipefail + +cd "$(dirname "$0")/.." +OUT="${1:-$(pwd)/dist}" +mkdir -p "$OUT" + +IMG="proxmox-monitor-agent-build:latest" + +docker build -f Dockerfile.build -t "$IMG" . +docker run --rm -v "$OUT":/out "$IMG" sh -c 'cp -v burrito_out/* /out/' + +echo +echo "Binaries written to $OUT:" +ls -la "$OUT"