sonarr: the runtime serves its watcher and tools, and its downloads step is a run-once process (hq ADR 0198)

The mesh-sonarr container and the mesh-sonarr-downloads step container go with the Dockerfile, build bases and bus credential. The step runs node on the bundle with its words in the process's env, the bound clients' files, the app's config.xml and its memory read where the mesh writes them; it still runs again when a binding it reads changes.
This commit is contained in:
jochen
2026-10-04 00:45:22 +02:00
parent 8fbed91540
commit f4d8faead0
2 changed files with 31 additions and 94 deletions
-27
View File
@@ -1,27 +0,0 @@
# sonarr'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/sonarr
COPY . .
RUN node /app/node_modules/typescript/bin/tsc client.ts plex.ts index.ts tools/index.ts downloads/settings.ts downloads/index.ts \
--module NodeNext --moduleResolution NodeNext --target ES2022 --outDir dist
FROM ${RUNTIME_BASE}
COPY --from=build /app/modules/sonarr/dist /app/modules/sonarr/dist
# Every serve-time entrypoint, loaded by the runtime in serve mode: tools and events serve, and a
# provider's provisioner runs its reconcile loop in the same process, with the broker connected —
# the convention novox/hq issues 060/061 settled.
ENV MESH_TOOL_MODULES=/app/modules/sonarr/dist/index.js,/app/modules/sonarr/dist/tools/index.js
# NOT dist/downloads/index.js: that is a step the host runs to completion, named by the `downloads`
# container's args as `mesh-tools run …` (novox/hq ADR 0052). Listed here it would run inside the
# serving sidecar too, and exit it.
+31 -67
View File
@@ -26,7 +26,6 @@
],
"consumes": [],
"own-secrets": {
"broker": "${dir:mesh-state}/broker",
"api-key": {
"path": "${dir:mesh-state}/api-key",
"taken": "at-start"
@@ -124,33 +123,6 @@
"api-key-init"
]
},
{
"id": "runtime",
"type": "container",
"name": "mesh-sonarr",
"network": "host",
"volumes": [
"${dir:mesh-state}/broker:/run/secrets/broker:ro",
"${dir:config}:/var/lib/sonarr/config:ro",
"${dir:mesh-state}/api-key:/run/secrets/api-key:ro",
"${dir:state}/plex-api.json:/run/plex/plex-api.json:ro",
"${dir:state}/plex-api.secret:/run/plex/plex-api.secret:ro"
],
"env": {
"MESH_BROKER_FILE": "/run/secrets/broker",
"MESH_SONARR_URL": "http://127.0.0.1:${port:8989}",
"MESH_SONARR_CONFIG_DIR": "/var/lib/sonarr/config",
"MESH_SONARR_API_KEY_FILE": "/run/secrets/api-key",
"MESH_PLEX_BIND_FILE": "/run/plex/plex-api.json",
"MESH_PLEX_TOKEN_FILE": "/run/plex/plex-api.secret"
},
"artifact": "runtime",
"restart-on": [
"needs-api-key",
"bound-plex-api",
"secret-plex-api"
]
},
{
"id": "downloads-config",
"type": "file",
@@ -166,34 +138,23 @@
},
{
"id": "downloads",
"type": "container",
"name": "mesh-sonarr-downloads",
"network": "host",
"run-once": true,
"volumes": [
"${dir:state}/downloads.json:/run/downloads/downloads.json:ro",
"${dir:state}/nzbget-api.json:/run/downloads/nzbget-api.json:ro",
"${dir:state}/nzbget-api.secret:/run/downloads/nzbget-api.secret:ro",
"${dir:state}/qbittorrent-api.json:/run/downloads/qbittorrent-api.json:ro",
"${dir:state}/qbittorrent-api.secret:/run/downloads/qbittorrent-api.secret:ro",
"${dir:state}/jackett-api.json:/run/downloads/jackett-api.json:ro",
"${dir:state}/jackett-api.secret:/run/downloads/jackett-api.secret:ro",
"${dir:config}:/var/lib/sonarr/config:ro",
"${dir:downloads-memory}:/var/lib/downloads"
"type": "process",
"name": "sonarr-downloads",
"artifact": "code",
"run": [
"node",
"downloads/index.js"
],
"run-once": true,
"env": {
"MESH_DOWNLOADS_APP": "sonarr",
"MESH_DOWNLOADS_API": "v3",
"MESH_DOWNLOADS_APP_URL": "http://127.0.0.1:${port:8989}",
"MESH_DOWNLOADS_APP_CONFIG": "/var/lib/sonarr/config/config.xml",
"MESH_DOWNLOADS_DIR": "/run/downloads",
"MESH_DOWNLOADS_SETTINGS": "/run/downloads/downloads.json",
"MESH_DOWNLOADS_MEMORY": "/var/lib/downloads/memory.json"
"MESH_DOWNLOADS_APP_CONFIG": "${dir:config}/config.xml",
"MESH_DOWNLOADS_DIR": "${dir:state}",
"MESH_DOWNLOADS_SETTINGS": "${dir:state}/downloads.json",
"MESH_DOWNLOADS_MEMORY": "${dir:downloads-memory}/memory.json"
},
"args": [
"run",
"/app/modules/sonarr/dist/downloads/index.js"
],
"restart-on": [
"downloads-config",
"bound-nzbget-api",
@@ -202,8 +163,7 @@
"secret-qbittorrent-api",
"bound-jackett-api",
"secret-jackett-api"
],
"artifact": "runtime"
]
}
],
"requires": [
@@ -233,23 +193,27 @@
"plex-api": "${dir:state}/plex-api.secret"
},
"build": {
"on": [
{
"arg": "BUILD_BASE",
"module": "mesh-tools",
"artifact": "build"
},
{
"arg": "RUNTIME_BASE",
"module": "mesh-tools",
"artifact": "runtime"
}
],
"artifacts": [
{
"name": "runtime",
"kind": "image",
"from": "Dockerfile"
"name": "code",
"kind": "bundle",
"language": "typescript",
"entrypoints": [
"index.js",
"tools/index.js",
"downloads/index.js"
],
"loads": [
"index.js",
"tools/index.js"
],
"env": {
"MESH_SONARR_URL": "http://127.0.0.1:${port:8989}",
"MESH_SONARR_CONFIG_DIR": "${dir:config}",
"MESH_SONARR_API_KEY_FILE": "${dir:mesh-state}/api-key",
"MESH_PLEX_BIND_FILE": "${dir:state}/plex-api.json",
"MESH_PLEX_TOKEN_FILE": "${dir:state}/plex-api.secret"
}
}
]
}