feat(sources): add Dokploy source #8

Manually merged
jfro merged 3 commits from feat/1-dokploy into main 2026-11-01 18:30:03 +00:00
Owner

Closes #1

Adds a Dokploy source (dokploy) with both roles, :problems and :context, reading Dokploy's REST API (/api/<router>.<procedure>, x-api-key header). Written against Dokploy v0.30.11's source.

What it reports

One service:<id> :incident signal per application, Compose service, and database:

  • last deploy failed (status: error): a warning while the previous containers still run, serious if containers can't be checked, critical if nothing is running. Why is the failed deployment's errorMessage, and the report starts at its finishedAt (looked up via deployment.all / deployment.allByCompose, for at most 10 failed services per poll)
  • deployed but not running (done with no running container): critical; a container stuck restarting: critical
  • Compose container exited with an error (e.g. Exited (2)) while others run: serious. Exited (0) one-shots and old Swarm tasks (<appName>.<slot>.<task>) don't count
  • deploying (running) → pending; idle (never deployed or stopped in Dokploy) → suppressed

Services come from overview.services (Dokploy ≥ 0.26, includes databases, appName, and server), falling back to project.all on a 404 (apps and Compose only, no container check, since it gives no appName). Containers come from docker.getContainers once per server the services run on, matched by appName.

Settings

URL (with or without /api), API key (secret), Only these projects, Check that containers are running (needs Docker read; a 403 says to grant it or turn this off), and the usual TLS trust fields.

Context queries

services, deployments (10 newest, with status, times, error), deployment_log (tail, default 200 lines, capped at 64 KB from the end), and containers for a service. context_summary says how many services and projects it sees and how many have failed deploys.

Logging

Every failed API call logs Dokploy: GET <path> <params> failed after N ms: <reason>, a failed poll logs the URL and duration, and successful polls log service/container counts at debug. A server whose docker ps fails (Dokploy returns nothing) is logged and skipped.

Screenshots

Settings form with example values, desktop and 390px:

Dokploy settings, desktop

Dokploy settings, 390px

(At 390px the app header's icons overflow to 472px on every page; that's on main too and is passed to the gap audit.)

Testing

  • test/lamplighter/sources/dokploy_test.exs: 19 tests with Req.Test stubs and fixtures shaped after overview.services / docker.getContainers (all statuses, two servers, Swarm and Compose names), the project.all fallback, 401/403/transport errors, and every context query
  • mix precommit: 625 tests pass, no warnings

Not yet run against a live Dokploy; the request/response shapes come from Dokploy's source (routers, @dokploy/trpc-openapi query coercion), not a running instance.

Closes #1 Adds a **Dokploy** source (`dokploy`) with both roles, `:problems` and `:context`, reading Dokploy's REST API (`/api/<router>.<procedure>`, `x-api-key` header). Written against Dokploy v0.30.11's source. ### What it reports One `service:<id>` `:incident` signal per application, Compose service, and database: - **last deploy failed** (`status: error`): a warning while the previous containers still run, serious if containers can't be checked, critical if nothing is running. *Why* is the failed deployment's `errorMessage`, and the report starts at its `finishedAt` (looked up via `deployment.all` / `deployment.allByCompose`, for at most 10 failed services per poll) - **deployed but not running** (`done` with no running container): critical; a container stuck `restarting`: critical - **Compose container exited with an error** (e.g. `Exited (2)`) while others run: serious. `Exited (0)` one-shots and old Swarm tasks (`<appName>.<slot>.<task>`) don't count - deploying (`running`) → pending; `idle` (never deployed or stopped in Dokploy) → suppressed Services come from `overview.services` (Dokploy ≥ 0.26, includes databases, appName, and server), falling back to `project.all` on a 404 (apps and Compose only, no container check, since it gives no appName). Containers come from `docker.getContainers` once per server the services run on, matched by appName. ### Settings URL (with or without `/api`), API key (secret), **Only these projects**, **Check that containers are running** (needs Docker read; a 403 says to grant it or turn this off), and the usual TLS trust fields. ### Context queries `services`, `deployments` (10 newest, with status, times, error), `deployment_log` (tail, default 200 lines, capped at 64 KB from the end), and `containers` for a service. `context_summary` says how many services and projects it sees and how many have failed deploys. ### Logging Every failed API call logs `Dokploy: GET <path> <params> failed after N ms: <reason>`, a failed poll logs the URL and duration, and successful polls log service/container counts at debug. A server whose `docker ps` fails (Dokploy returns nothing) is logged and skipped. ### Screenshots Settings form with example values, desktop and 390px: ![Dokploy settings, desktop](https://git.knope.dev/attachments/95236225-7179-4d66-8cae-7bf918f1fb8a) ![Dokploy settings, 390px](https://git.knope.dev/attachments/1225fc1c-ae41-4033-8613-a30898369881) (At 390px the app header's icons overflow to 472px on every page; that's on `main` too and is passed to the gap audit.) ### Testing - `test/lamplighter/sources/dokploy_test.exs`: 19 tests with `Req.Test` stubs and fixtures shaped after `overview.services` / `docker.getContainers` (all statuses, two servers, Swarm and Compose names), the `project.all` fallback, 401/403/transport errors, and every context query - `mix precommit`: 625 tests pass, no warnings Not yet run against a live Dokploy; the request/response shapes come from Dokploy's source (routers, `@dokploy/trpc-openapi` query coercion), not a running instance.
jfro added this to the v1.0 milestone 2026-11-01 16:31:44 +00:00
feat(sources): add Dokploy source
All checks were successful
CI / test (pull_request) Successful in 55s
df7f930419
Reports Dokploy applications, Compose services, and databases whose last
deploy failed (with the deployment's error message) or whose containers
aren't running, read from overview.services (or project.all on older
Dokploy) and docker.getContainers per server. As a context source it
lists services, deployments, deployment logs, and containers. Logs every
failed API call with its path and duration.

Closes #1
Author
Owner

Review (Nye): checked against Dokploy v0.30.11 source. The endpoints, fields and tRPC query coercion all match, and precommit passes (625/625).

F3 (low): containers are matched by appName prefix plus any of . - _, so a down app web picks up a running web-api.1.<task> and is reported as running. Suggest anchoring Swarm tasks as ^appName\.\d+\.[a-z0-9]+$ and stack tasks as ^appName_.+\.\d+\.[a-z0-9]+$, and keeping the dash form for Compose only (^appName-.+-\d+$). Repro test: test/review/dokploy_prefix_test.exs (sent to UW).

Non-blocking:

  • In Dokploy, docker: read also gates docker.stopContainer, removeContainer and writeContainerFile. The setup guide should warn that the container check's permission lets the key stop or remove containers.
  • The deployments, deployment_log and containers context queries ignore the source's project filter (find_service uses projects: [], and readLogs takes any deploymentId). That's fine if intended; worth a line in the moduledoc.
Review (Nye): checked against Dokploy v0.30.11 source. The endpoints, fields and tRPC query coercion all match, and precommit passes (625/625). **F3 (low):** containers are matched by `appName` prefix plus any of `. - _`, so a down app `web` picks up a running `web-api.1.<task>` and is reported as running. Suggest anchoring Swarm tasks as `^appName\.\d+\.[a-z0-9]+$` and stack tasks as `^appName_.+\.\d+\.[a-z0-9]+$`, and keeping the dash form for Compose only (`^appName-.+-\d+$`). Repro test: `test/review/dokploy_prefix_test.exs` (sent to UW). Non-blocking: - In Dokploy, `docker: read` also gates `docker.stopContainer`, `removeContainer` and `writeContainerFile`. The setup guide should warn that the container check's permission lets the key stop or remove containers. - The `deployments`, `deployment_log` and `containers` context queries ignore the source's project filter (find_service uses `projects: []`, and readLogs takes any deploymentId). That's fine if intended; worth a line in the moduledoc.
fix(dokploy): match containers by exact Swarm, Compose and stack names
All checks were successful
CI / test (pull_request) Successful in 24s
9de9067d4b
An app named "web" picked up "web-api"'s running tasks through the
appName prefix match and was reported as running while down. Match
applications as <appName>.<slot>.<task> only, and Compose services as
<appName>-<service>-<n> or <appName>_<service>.<slot>.<task>.

Also note in the docs that Dokploy's Docker read permission can stop
containers, and that context queries ignore the project filter.
jfro force-pushed feat/1-dokploy from 9de9067d4b
All checks were successful
CI / test (pull_request) Successful in 24s
to 8610690ebb
All checks were successful
CI / test (pull_request) Successful in 24s
2026-11-01 16:53:56 +00:00
Compare
Author
Owner

Re-review (Nye) at 8610690 (rebase of 9de9067 on main): the F3 fix holds for Swarm replicated services and precommit passes (627).

F6 (low), still open: the exact-name match has two gaps.

  1. Global-mode Swarm services name their tasks <service>.<nodeID>.<taskID> (no numeric slot), so the match drops them; a global app whose tasks keep restarting shows as running.
  2. Compose containers are still matched by prefix (<appName>-), so a Compose app app borrows app-two's containers, the same hole as F3. Compose names are <project>-<service>-<n>; match on the com.docker.compose.project label (or ^<appName>-[^-]+-\d+$) instead.

Failing test: test/review/dokploy_match_test.exs (2 of 3 fail on 8610690).

Re-review (Nye) at 8610690 (rebase of 9de9067 on main): the F3 fix holds for Swarm replicated services and precommit passes (627). **F6 (low), still open:** the exact-name match has two gaps. 1. Global-mode Swarm services name their tasks `<service>.<nodeID>.<taskID>` (no numeric slot), so the match drops them; a global app whose tasks keep restarting shows as running. 2. Compose containers are still matched by prefix (`<appName>-`), so a Compose app `app` borrows `app-two`'s containers, the same hole as F3. Compose names are `<project>-<service>-<n>`; match on the `com.docker.compose.project` label (or `^<appName>-[^-]+-\d+$`) instead. Failing test: `test/review/dokploy_match_test.exs` (2 of 3 fail on 8610690).
jfro force-pushed feat/1-dokploy from 8610690ebb
All checks were successful
CI / test (pull_request) Successful in 24s
to 25ccc76383
All checks were successful
CI / test (pull_request) Successful in 25s
2026-11-01 17:50:42 +00:00
Compare
Author
Owner

Re-review at 25ccc76 (Nye): ready.

  • F6 fixed: global-mode Swarm tasks (<app>.<nodeID>.<task>) now match, so a restarting global app reports failing; each container goes to the longest appName that fits on its server, so "app" no longer picks up "app-two"'s containers.
  • mix precommit: 664 tests pass. CI green.
  • Extra edge tests pass: the longer appName only wins on its own server; a stack with replicated and global tasks is judged by all of them.
  • Known limit (documented in the code): with no container labels, Compose "app" with its own service "two-db" next to a Compose "app-two" on the same server gives "app-two-db-1" to app-two. Fine for 1.0.
  • Nit (no change needed): container_patterns/1 is rebuilt per container×service pair; could precompute per service.
Re-review at 25ccc76 (Nye): ready. - F6 fixed: global-mode Swarm tasks (`<app>.<nodeID>.<task>`) now match, so a restarting global app reports failing; each container goes to the longest appName that fits on its server, so "app" no longer picks up "app-two"'s containers. - `mix precommit`: 664 tests pass. CI green. - Extra edge tests pass: the longer appName only wins on its own server; a stack with replicated and global tasks is judged by all of them. - Known limit (documented in the code): with no container labels, Compose "app" with its own service "two-db" next to a Compose "app-two" on the same server gives "app-two-db-1" to app-two. Fine for 1.0. - Nit (no change needed): `container_patterns/1` is rebuilt per container×service pair; could precompute per service.
jfro manually merged commit 904a1f9b43 into main 2026-11-01 18:30:03 +00:00
Sign in to join this conversation.
No description provided.