build: stamp the agent image with the checkout's version

The container build was the one build path that could not learn a version: the
build context excludes .git, so it has to be passed in, and nothing passed one
-- Compose handed the Dockerfile no build args, so every locally built agent
answered "dev" while the daemon reported the tag. The Taskfile now derives the
version from git describe once, for both the host binaries and the image, and
task image:agent passes it through.

docker compose build agent also failed outright: the service named the image by
digest, and Compose refuses to tag a digest. The build-only service names it by
tag now; what a task container runs is still pinned in the daemon's own
[containers] image.
This commit is contained in:
sam committed 2026-10-25 20:24:27 +11:00
1 parent 2965f8354c
commit b036e0b35e
3 files changed
+26 -7

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@
# Pre-installs system tools agents can't install themselves (no apt, no sudo).
# Language packages are installed at runtime via uv/npm/go.
#
# Build: docker build -t archie-agent:latest .
# Build: task image:agent (or docker build --build-arg RUNTIME_VERSION=<ver>)
# A build that names no version stamps none, and the agent reports dev.
# ── builder ──
FROM golang:1.27-trixie AS builder
+14 -2
View File
@@ -2,6 +2,11 @@ version: "3"
vars:
BIN_DIR: "bin"
# The version a build reports: the nearest tag with the distance and commit,
# or a bare commit when the checkout has no tags (a shallow clone). A build
# should not answer "dev" only because the caller did not name a version.
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo dev
tasks:
fmt:
@@ -225,8 +230,8 @@ tasks:
build:
desc: Build archie services and agent binaries
vars:
GATEWAY_VERSION: '{{.GATEWAY_VERSION | default "dev"}}'
RUNTIME_VERSION: '{{.RUNTIME_VERSION | default "dev"}}'
GATEWAY_VERSION: '{{.GATEWAY_VERSION | default .VERSION}}'
RUNTIME_VERSION: '{{.RUNTIME_VERSION | default .VERSION}}'
SERVICE_LDFLAGS: >-
-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary
-X github.com/samcharles93/archie-core/internal/buildinfo.Version={{.GATEWAY_VERSION}}
@@ -262,6 +267,13 @@ tasks:
cmds:
- go test -short ./...
image:agent:
desc: Build the agent image stamped with this checkout's version
# Compose owns the image build; this only supplies the version, which a
# plain `docker build` has no way to learn from a context that excludes .git.
cmds:
- RUNTIME_VERSION={{.VERSION}} docker compose build agent
check:
desc: Run the full quality gate
# Finish mutations before starting parallel checks.
+10 -4
View File
@@ -8,7 +8,7 @@
# Embedded NATS is the normal deployment and needs no Compose service.
# State Store DB: docker compose up -d postgres
# External broker: docker compose up -d nats
# Build worker: docker compose build agent
# Build worker: task image:agent (stamps this checkout's version)
# Profile image: docker compose build agent-net
# Stop external: docker compose down
# Logs: journalctl --user -u archied -f (the daemon)
@@ -86,10 +86,16 @@ services:
build:
context: .
dockerfile: Dockerfile
# Pinned to a verified digest -- archie-agent has no published semver
# tag yet (CI only pushes :latest). See
# Stamped into the agent so the version it reports is the one the rest of
# the install reports. `task image:agent` passes this checkout's version;
# a bare `docker build` passes nothing and the agent answers dev.
args:
RUNTIME_VERSION: ${RUNTIME_VERSION:-dev}
# A tag, not the digest: Compose refuses to build an image it is told to
# name by digest. The digest a task container actually runs is pinned in
# the daemon's own [containers] image, so nothing here decides it. See
# deployments/systemd-user-service.md#pinning-the-archie-agent-image.
image: ghcr.io/samcharles93/archie-agent@sha256:870f1b1357979cfea23fccacb24166ebeb9ab321708ef2c2b218a763ed99b090
image: ghcr.io/samcharles93/archie-agent:latest
# ── example agent profile image ─────────────────────────────────────
# The agent image plus network lookup tools, for a workflow that names