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:
1 parent
1e1a055f98
commit
e8568259e8
3 files changed
+26
-7
No files matched your search
+14
-2
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user