route-adapter: its step is a run-once process (hq ADR 0198)

The mesh-route-adapter container goes with its Dockerfile and build bases. The step runs node on the bundle as a run-once process, reading what the mesh contributed and its config where the mesh writes them and writing the proxy's dynamic directory at the path the container used to mount; it still runs again when a route or its config changes.
This commit is contained in:
jochen
2026-10-04 00:52:31 +02:00
parent 59c42b2086
commit 35ef72081f
2 changed files with 14 additions and 52 deletions
-24
View File
@@ -1,24 +0,0 @@
# route-adapter's runtime: the tool runtime, carrying this module's compiled code.
#
# **Built from this module's own directory and nothing else.** The sdk and the tool runtime are in
# the base images, published like any other artifact — which is what makes this buildable by the
# mesh from a repository and a path (novox/hq ADR 0069) rather than only on a workstation that
# happens to have the siblings.
#
# Two bases, named rather than pinned (novox/hq issue 044): the image this is COMPILED in and the
# image it RUNS in — the second must not carry a compiler. Declared in module.json's `build.on`.
ARG BUILD_BASE
ARG RUNTIME_BASE
FROM ${BUILD_BASE} AS build
WORKDIR /app/modules/route-adapter
COPY . .
RUN node /app/node_modules/typescript/bin/tsc adapter.ts index.ts \
--module NodeNext --moduleResolution NodeNext --target ES2022 --outDir dist
FROM ${RUNTIME_BASE}
COPY --from=build /app/modules/route-adapter/dist /app/modules/route-adapter/dist
# **No MESH_TOOL_MODULES, deliberately.** This module serves no tool and consumes no event: it is a
# step the host runs to completion, named by the container's `args` as `mesh-tools run …`. Setting a
# serve-time entrypoint here would give the image a second way to be started — one that connects to
# the broker and never exits.
+14 -28
View File
@@ -47,23 +47,18 @@
}, },
{ {
"id": "adapt", "id": "adapt",
"type": "container", "type": "process",
"name": "mesh-route-adapter", "name": "route-adapter",
"artifact": "runtime", "artifact": "code",
"run-once": true, "run": [
"volumes": [ "node",
"${dir:routes-dir}/mesh.json:${dir:routes-dir}/mesh.json:ro", "index.js"
"${dir:state}/config.json:/run/config/config.json:ro",
"${access:dynamic}:/services/traefik/dynamic"
], ],
"run-once": true,
"env": { "env": {
"MESH_RECEIVES": "${dir:routes-dir}/mesh.json", "MESH_RECEIVES": "${dir:routes-dir}/mesh.json",
"MESH_ROUTE_ADAPTER_CONFIG": "/run/config/config.json" "MESH_ROUTE_ADAPTER_CONFIG": "${dir:state}/config.json"
}, },
"args": [
"run",
"/app/modules/route-adapter/dist/index.js"
],
"restart-on": [ "restart-on": [
"received-route", "received-route",
"config" "config"
@@ -71,23 +66,14 @@
} }
], ],
"build": { "build": {
"on": [
{
"arg": "BUILD_BASE",
"module": "mesh-tools",
"artifact": "build"
},
{
"arg": "RUNTIME_BASE",
"module": "mesh-tools",
"artifact": "runtime"
}
],
"artifacts": [ "artifacts": [
{ {
"name": "runtime", "name": "code",
"kind": "image", "kind": "bundle",
"from": "Dockerfile" "language": "typescript",
"entrypoints": [
"index.js"
]
} }
] ]
} }