Skip to content

feat(deploy): the installation registry in the control plane's Compose project (part of #215) - #530

Merged
samuelmbabhazi merged 3 commits into
mainfrom
feat/215-registry-service
Nov 27, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
feat/215-registry-service

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Part of #215 (M3.3), following ADR 0030. This puts the installation's registry in the control plane's Compose project and serves it under /v2/ on the control plane's name. It builds on #529 (token endpoint and grants) and contains its commit until #529 merges. The base is main so that merging #529 does not close this PR.

What changed

  • registry service in deploy/control-plane/compose.yml: CNCF Distribution 3.1.2, pinned by digest.
    • It is configured by the new registry.yml, with token authentication. Its realm (the control plane's /api/v1/registry/token) and its service (SHIPKEEP_DOMAIN) come from the environment.
    • Images live in the registry-data volume, which is not in the instance backup.
    • It reads the JWKS from the registry-auth volume, which the control plane writes (REGISTRY_JWKS_FILE) and the registry mounts read-only.
    • It starts once the control plane is healthy, so the key exists.
  • Separate machine: the Compose Caddy sends /v2 and /v2/* to the registry uncompressed, and everything else to the API as before.
  • Single machine:
    • compose.single-machine.yml publishes the registry on 127.0.0.1:5000, in the control plane's slice, capped at 256 MiB;
    • the agent keeps a third fixed route before the control plane's: shipkeep-control-plane-registry, with host plus path /v2, /v2/*, to control_plane.route.registry;
    • that setting defaults to 127.0.0.1:5000, so existing agent configurations need no change, and a non-loopback value is refused. No action can name or remove the route (tested).
  • Image: the control plane image creates /var/lib/shipkeep-registry, owned by node, so that the new volume is writable.
  • Installer and bundle:
    • the bundle and the installer ship registry.yml;
    • the single-machine checks refuse a busy port 5000;
    • install_test.sh checks the merged Compose configuration.
  • Docs: INSTALL (files, upgrade, port, route) and SPEC.

How it was tested

  • Distribution 3.1.2: the environment variables do override realm and service from registry.yml. Tested against a real registry:3.1.2 with an EdDSA token: 401 with the right realm, then 202 for an allowed push.
  • Caddyfile: caddy adapt with the pinned Caddy image confirms the routing (/v2 and /v2/* to the registry, the rest compressed to the API).
  • Agent routes on a real Caddy (pinned image, internal TLS):
    • /v2, /v2/ and /v2/org/app/blobs/uploads/ reach the registry upstream;
    • /, /api/v1/registry/token, /v2x and /web/v2/ reach the control plane;
    • plain HTTP gets a 308 to HTTPS;
    • a Host header with another port matches no route, the existing bound.
  • Merged Compose configuration (docker compose config with both files): realm, service, port 127.0.0.1:5000, depends_on healthy, the read-only volumes, the slice and the limit.
  • Go: go test ./agent/... and golangci-lint are clean. New cases cover the route order and paths, default and named registry upstreams, non-loopback values refused, and the fixed routes out of reach of RemoveRoute.

Security considerations

  • The registry accepts only tokens signed with the installation's key: anonymous requests get 401 with the realm. Its port is published on loopback only, and only on a single machine.
  • The JWKS volume holds only the public key. The private key never leaves the control plane's database, where it is encrypted.
  • A route written before this change keeps working: the agent adds the registry route ahead of it, and an action can never remove it.
  • Known limit, per ADR 0030: on a single machine, the server's Docker reaches the registry through the control plane's public name, via the egress proxy. Behind a NAT that does not loop back, Git builds do not work in this version. INSTALL will say so once builds ship.

…t of #215)

ADR 0030: Distribution's token authentication with the control plane as token service. A grant (pull, or pull and push for a build) is issued for an action until its deadline, its password stored hashed and the grant audited. GET /api/v1/registry/token answers a five-minute EdDSA token for the grant's repository only, signed with a new installation key whose public half is written as a JWKS for Distribution.

Signed-off-by: samuel mbabhazi <[email protected]>
…e project (part of #215)

ADR 0030: Distribution with token authentication, its key read from the JWKS the control plane writes, served under /v2/ on the control plane's name: by the Compose Caddy, and on a single machine by the server's Caddy through a route the agent keeps before the control plane's, to 127.0.0.1:5000 by default.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e824b1b and 14fd2ea.

Files selected for processing: 17

  • agent/internal/actions/reserved_host_test.go
  • agent/internal/agent/agent.go
  • agent/internal/agent/controlplane_route_test.go
  • agent/internal/caddy/caddy.go
  • agent/internal/caddy/controlplane_route_test.go
  • agent/internal/config/config.go
  • agent/internal/config/config_test.go
  • deploy/control-plane.Dockerfile
  • deploy/control-plane/Caddyfile
  • deploy/control-plane/build-bundle.sh
  • deploy/control-plane/compose.single-machine.yml
  • deploy/control-plane/compose.yml
  • deploy/control-plane/install.sh
  • deploy/control-plane/install_test.sh
  • deploy/control-plane/registry.yml
  • docs/INSTALL.md
  • docs/SPEC.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…vice

Signed-off-by: samuel mbabhazi <[email protected]>

# Conflicts:
#	apps/api/prisma/migrations/20261127120000_registry_grants/migration.sql
#	apps/api/prisma/schema.prisma
#	apps/api/src/modules/registries/application/ports.ts
#	apps/api/src/modules/registries/application/registry-grants.ts
#	apps/api/src/modules/registries/application/registry-tokens.ts
#	apps/api/src/modules/registries/domain/registry-token.spec.ts
#	apps/api/src/modules/registries/domain/registry-token.ts
#	apps/api/src/modules/registries/registry-distribution.integration.spec.ts
#	apps/api/src/modules/registries/registry-tokens-http.integration.spec.ts
#	docs/SPEC.md
@samuelmbabhazi
samuelmbabhazi merged commit fbd24a2 into main Nov 27, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/215-registry-service branch November 27, 2026 10:36
samuelmbabhazi added a commit that referenced this pull request Nov 27, 2026
… then deploys the image (part of #215) (#537)

Part of #215 (M3.3), per ADR 0030. This connects the pieces already
merged: the registry and its grants (#529, #530), the agent's
`BuildImage` (#533) and the build lane (#532). A Git application with a
Dockerfile now builds when it deploys, and its replicas run the image
that was built.

## What changed

- **Configuration**: an application whose configuration is a
repository's may use `build.type: dockerfile`. Railpack and Nixpacks are
still refused with `unsupported_build_type` (new text, in the web UI and
in French). An application created from an image still runs an image.
- **Release**:
- `releaseDraft(config, { repository })` plans a build. Its image is
`<control plane host>/<organization>/<application>:<release number>`
(`builtImage`), set once the store knows the number;
- `repositoryPath` reads paths the way the agent does: `./api/` → `api`,
`.` → the root;
  - the commit was already kept (#527).
- **Planner** (`building` and `built` stages): the replicas are placed
first, then `build_image` runs on the first one's server, at the commit,
with the context, the Dockerfile and the args. Its digest becomes the
release's (`record_build`). A failed build gives its cause in words: its
output, its time limit, a server without a builder.
- **Runner**:
- the GitHub token is minted **outside any transaction**
(`RepositorySource.buildAccess`): read access to that one repository,
under its current name. If GitHub cannot be reached, the run waits and
tries again;
- the push grant (#529) is issued at enqueue time and lasts as long as
the action;
  - `release.image_built` is audited with the digest and the commit;
- every pull from the installation's registry carries a **pull-only
grant**.
- **Store**: an action's `buildImage.imageDigest` is read back, only if
it is a valid `sha256:` digest.
- **SPEC**: the build stage. Open question: the token is not revoked
when the build ends yet (it expires within the hour).

## How it was tested

- **Planner unit tests**:
- the full order, from `queued` through `building` and `built` to
`succeeded`;
- the exact build step (first replica's node, normalized paths, the
tag), with the default context and Dockerfile;
  - every replica pulls `<repository>@<built digest>`;
  - each failure cause and its text, with nothing deployed afterwards;
  - no digest, no commit, a release already built.
- **Agent action**: `BuildImage` carries the URL, the commit, the token
and the push grant, and round-trips through protobuf. A build without
its access is refused.
- **Integration** (`git-builds.integration.spec.ts`, PostgreSQL, fake
GitHub, real pipeline and token endpoint):
- the deploy creates `…/<app>:1`, and the build is the only action
queued;
  - the token is scoped to `repositoryIds: [777]`, `contents: read`;
- the push grant is accepted by the token endpoint for pull and push on
that repository;
  - after the agent's answer, the digest is recorded and audited;
- the pull goes to `<repo>@<digest>` with a grant that gets `pull` only;
- both grants are audited, and the token never appears in the audit log.
- **Suites**:
  - API: lint, typecheck, 411 unit tests;
- integration, all suites run: only the known environment failures
(PostgreSQL 18 error codes, specs that need a container runtime);
  - web: 398 tests.

## Security considerations

- **The token** is minted for one repository and read access, travels
only inside the encrypted action, and is never logged or audited. It is
not revoked yet (open question).
- **The grants**: pushing only for the build, only to the application's
repository, until the action's deadline. Servers only pull.
- **No GitHub call holds a database transaction.**

Signed-off-by: samuel mbabhazi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants