From 64dda9cb045d31701019c65455cd9ba9a9f63ae1 Mon Sep 17 00:00:00 2001 From: Carsten Date: Thu, 23 Apr 2026 07:51:30 +0200 Subject: [PATCH] fix(agent): derive @version from BUILD_ID so Burrito re-extracts per build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Burrito keys its on-host install directory on `{release}_erts-{ertsver}_{appver}` and skips extraction when `_metadata.json` is already present for that version. With a static `@version "0.1.0"` in mix.exs, every new build landed in the same cached dir on the target host — silently running stale code. Now @version resolves to `0.1.0+` where BUILD_ID is the git short SHA (or `dev-` fallback). scripts/build-linux.sh computes it on the host and passes it through Dockerfile.build's ARG/ENV, so every commit produces a distinct Burrito install dir and fresh extraction is guaranteed. Co-Authored-By: Claude Opus 4.7 (1M context) --- agent/Dockerfile.build | 5 +++++ agent/mix.exs | 13 +++++++++++-- agent/scripts/build-linux.sh | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/agent/Dockerfile.build b/agent/Dockerfile.build index 4bed0b0..eebef23 100644 --- a/agent/Dockerfile.build +++ b/agent/Dockerfile.build @@ -28,6 +28,11 @@ COPY lib lib COPY config config RUN mix deps.compile + +# BUILD_ID is injected by scripts/build-linux.sh (typically the git short SHA). +# Declared here — not earlier — so deps.compile stays cacheable across builds. +ARG BUILD_ID=dev +ENV BUILD_ID=${BUILD_ID} RUN mix release # Default: print the produced artifacts diff --git a/agent/mix.exs b/agent/mix.exs index 888cbcf..215de6e 100644 --- a/agent/mix.exs +++ b/agent/mix.exs @@ -1,12 +1,12 @@ defmodule ProxmoxAgent.MixProject do use Mix.Project - @version "0.1.0" + @version_base "0.1.0" def project do [ app: :agent, - version: @version, + version: version(), elixir: "~> 1.17", start_permanent: Mix.env() == :prod, deps: deps(), @@ -22,6 +22,15 @@ defmodule ProxmoxAgent.MixProject do ] end + # Version is built per-invocation so every commit produces a distinct Burrito + # install directory on the target host (`_erts-_`). + # Without this, Burrito sees an existing `_metadata.json` for the same version + # and skips extraction, silently running stale cached code. + defp version do + build_id = System.get_env("BUILD_ID") || "dev" + "#{@version_base}+#{build_id}" + end + defp deps do [ {:slipstream, "~> 1.1"}, diff --git a/agent/scripts/build-linux.sh b/agent/scripts/build-linux.sh index 7f795c4..30ff50b 100755 --- a/agent/scripts/build-linux.sh +++ b/agent/scripts/build-linux.sh @@ -9,7 +9,14 @@ mkdir -p "$OUT" IMG="proxmox-monitor-agent-build:latest" -docker build -f Dockerfile.build -t "$IMG" . +# Unique per-build identifier. Git short SHA when available; otherwise a +# timestamp fallback. Passed to Docker so @version in mix.exs expands to +# `0.1.0+` — this keys Burrito's on-host install dir so new builds +# always re-extract instead of running stale cached code. +BUILD_ID="$(git rev-parse --short=10 HEAD 2>/dev/null || echo "dev-$(date +%s)")" +echo "Build ID: $BUILD_ID" + +docker build -f Dockerfile.build --build-arg BUILD_ID="$BUILD_ID" -t "$IMG" . docker run --rm -v "$OUT":/out "$IMG" sh -c 'cp -v burrito_out/* /out/' echo