Merge pull request 'build-agent: the build machine as a node role every machine can hold (hq ADR 0190)' (#231) from feat/build-agent into main
This commit was merged in pull request #231.
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
ARG GO_BASE
|
||||||
|
ARG ALPINE_BASE
|
||||||
|
# build-agent's image: the build machine itself, compiled into a container (novox/hq ADR 0190).
|
||||||
|
#
|
||||||
|
# **The source is not vendored here.** builder's actual code — cmd/mesh-builder, internal/builder,
|
||||||
|
# internal/catalogue — lives in the mesh-controller repository, the same control plane it is one
|
||||||
|
# half of. This module ships the packaging, not a second copy of the source, so the build context
|
||||||
|
# is the mesh-controller repository root (declared under build.artifacts[].context), and this
|
||||||
|
# Dockerfile compiles ./cmd/mesh-builder from it — the same shape route-proxy already uses for the
|
||||||
|
# same reason.
|
||||||
|
FROM ${GO_BASE} AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
COPY . .
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -o /mesh-builder ./cmd/mesh-builder
|
||||||
|
|
||||||
|
# Unlike mesh-controller's own FROM scratch (ADR 0006: nothing to audit but one binary), the build
|
||||||
|
# machine's whole job is shelling out to git and docker — it needs a real userland to do that in,
|
||||||
|
# not a second copy of either tool vendored into this image. apk installs both from the base's own
|
||||||
|
# packages, not fetched on its own at build time.
|
||||||
|
FROM ${ALPINE_BASE}
|
||||||
|
RUN apk add --no-cache docker-cli git
|
||||||
|
COPY --from=build /mesh-builder /usr/local/bin/mesh-builder
|
||||||
|
ENTRYPOINT ["/usr/local/bin/mesh-builder"]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# build-agent
|
||||||
|
|
||||||
|
The mesh's build machine as a role every machine can hold (novox/hq ADR 0190). It holds the node seat
|
||||||
|
`node-build-agent`: every holder pulls one build at a time from the role's one work queue when it is
|
||||||
|
idle, so a tier of many images is built by as many machines as hold the seat and are online, and a
|
||||||
|
machine that is off builds nothing and blocks nothing. The controller asks the role, never a machine;
|
||||||
|
the outcome names the machine that built it.
|
||||||
|
|
||||||
|
What a holding machine needs is what the builder always needed, said here once: a container runtime
|
||||||
|
(the socket is mounted), the artifact store and the package registry as provisions, a workspace, and
|
||||||
|
the bus credential. The code is `cmd/mesh-builder` in the mesh-controller repository, compiled from
|
||||||
|
that repository's main (`build.artifacts[].context`); this module ships the packaging.
|
||||||
|
|
||||||
|
Assign it to every machine with a container runtime. It replaces `builder`, the one-holder form of the
|
||||||
|
same thing; retire that once this is assigned where it was.
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"module": "build-agent",
|
||||||
|
"version": "1",
|
||||||
|
"capabilities": [
|
||||||
|
"container-runtime"
|
||||||
|
],
|
||||||
|
"claims": [
|
||||||
|
{
|
||||||
|
"name": "node-build-agent",
|
||||||
|
"scope": "node"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requires": [
|
||||||
|
"artifact-store",
|
||||||
|
"npm-package-registry"
|
||||||
|
],
|
||||||
|
"binds": {
|
||||||
|
"npm-package-registry": "${dir:mesh-state}/package-registry.json"
|
||||||
|
},
|
||||||
|
"secrets": {
|
||||||
|
"npm-package-registry": "${dir:mesh-state}/package-registry.secret"
|
||||||
|
},
|
||||||
|
"own-secrets": {
|
||||||
|
"broker": "${dir:mesh-state}/broker"
|
||||||
|
},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"id": "mesh-state",
|
||||||
|
"type": "directory",
|
||||||
|
"mode": "0700",
|
||||||
|
"place": "mesh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "workspace",
|
||||||
|
"type": "directory",
|
||||||
|
"mode": "0700"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "agent-env",
|
||||||
|
"type": "file",
|
||||||
|
"path": "${dir:mesh-state}/build-agent.env",
|
||||||
|
"mode": "0600",
|
||||||
|
"content": "MESH_BROKER_FILE=/run/mesh/broker\nMESH_NODE=${machine:name}\nMESH_REGISTRY=${bound:artifact-store:at}:${bound:artifact-store:port}\nMESH_PACKAGE_BINDING=/run/mesh/package-registry.json\nMESH_NPM_TOKEN_FILE=/run/mesh/package-registry.secret\nMESH_WORKSPACE=${dir:workspace}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "server",
|
||||||
|
"type": "container",
|
||||||
|
"name": "mesh-build-agent",
|
||||||
|
"artifact": "server",
|
||||||
|
"env-file": [
|
||||||
|
"${dir:mesh-state}/build-agent.env"
|
||||||
|
],
|
||||||
|
"volumes": [
|
||||||
|
"${dir:mesh-state}:/run/mesh:ro",
|
||||||
|
"${dir:workspace}:${dir:workspace}",
|
||||||
|
"/var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
],
|
||||||
|
"restart-on": [
|
||||||
|
"agent-env"
|
||||||
|
],
|
||||||
|
"network": "host"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"build": {
|
||||||
|
"artifacts": [
|
||||||
|
{
|
||||||
|
"name": "server",
|
||||||
|
"kind": "image",
|
||||||
|
"from": "Dockerfile",
|
||||||
|
"context": {
|
||||||
|
"seat": "git",
|
||||||
|
"repository": "novox/mesh-controller",
|
||||||
|
"ref": "main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"on": [
|
||||||
|
{
|
||||||
|
"arg": "GO_BASE",
|
||||||
|
"image": "golang@sha256:8ac98ca534ac3f51e1f420a1dd2c15e74c75cfa0f23f3ad27eb5d7236c349a0c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"arg": "ALPINE_BASE",
|
||||||
|
"image": "alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user