diff --git a/Dockerfile b/Dockerfile index 98563ced6..d73f810a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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=) +# A build that names no version stamps none, and the agent reports dev. # ── builder ── FROM golang:1.27-trixie AS builder diff --git a/Taskfile.yml b/Taskfile.yml index a17e412ec..1c55be275 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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. diff --git a/docker-compose.yml b/docker-compose.yml index 6f5dfad93..00981d8b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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