Skip to content

feat(api): the pipeline builds a Git application with its Dockerfile, then deploys the image (part of #215) - #537

Merged
samuelmbabhazi merged 3 commits into
mainfrom
feat/215-pipeline-build
Nov 27, 2026
Merged

samuelmbabhazi merged 3 commits into
mainfrom
feat/215-pipeline-build

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

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 (feat(api): a verified push deploys its commit (closes #213) #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 (feat(api): the installation registry's token endpoint and grants (part of #215) #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.

… then deploys the image (part of #215)

ADR 0030: a Git application with build.type dockerfile gets a building stage. Its replicas are placed first and the first one's server builds at the release's commit, with a GitHub token that reads that repository only, minted outside any transaction, and a registry grant that pushes the release's tag. The digest it answers becomes the release's, audited as release.image_built; every pull from the installation's registry then carries a grant that only pulls.

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 3 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 8da06ea and 61063a8.

Files selected for processing: 22

  • apps/api/src/modules/apps/application/ports.ts
  • apps/api/src/modules/apps/domain/application.ts
  • apps/api/src/modules/apps/git-applications-http.integration.spec.ts
  • apps/api/src/modules/deployments/application/deployment-commands.ts
  • apps/api/src/modules/deployments/application/deployment-pipeline.spec.ts
  • apps/api/src/modules/deployments/application/deployment-pipeline.ts
  • apps/api/src/modules/deployments/application/ports.ts
  • apps/api/src/modules/deployments/domain/pipeline.spec.ts
  • apps/api/src/modules/deployments/domain/pipeline.ts
  • apps/api/src/modules/deployments/domain/release.ts
  • apps/api/src/modules/deployments/git-builds.integration.spec.ts
  • apps/api/src/modules/deployments/infrastructure/agent-steps.spec.ts
  • apps/api/src/modules/deployments/infrastructure/agent-steps.ts
  • apps/api/src/modules/deployments/infrastructure/agent-steps.vectors.spec-helpers.ts
  • apps/api/src/modules/deployments/infrastructure/prisma-deployment.store.ts
  • apps/api/src/modules/deployments/infrastructure/prisma-pipeline.store.ts
  • apps/api/src/modules/git/application/github-sources.ts
  • apps/api/src/modules/registries/registries.module.ts
  • apps/web/src/app/delivery/github-application-form.spec.ts
  • apps/web/src/app/delivery/github-application-form.ts
  • apps/web/src/app/ui/fr.ts
  • 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

@samuelmbabhazi
samuelmbabhazi merged commit 09c9fc7 into main Nov 27, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/215-pipeline-build branch November 27, 2026 12:27
samuelmbabhazi added a commit that referenced this pull request Nov 27, 2026
…#539)

Part of #265 (screen 15, "the build and release log of one deployment,
streamed while it runs").

## What changed

**API**
- `GET
…/applications/{applicationId}/deployments/{deploymentId}/build-output`
(`environment.read`, also open to API tokens with that permission)
answers one deployment's build output, oldest first: `kept`, and `lines`
with `time`, `line`, `truncated`.
- It reads the lines the control plane labelled with that deployment
(#534): `instance` and `stream` `build`, field `deployment`. By default
it starts an hour before the deployment started, because the agent
stamps lines with its own clock. A live view passes `from`, the exact
time of its last line, to the nanosecond. `limit` defaults to 500, which
is also the maximum.
- A deployment of another application is not found, checked in SQL
(`deployments.application_id`).
- Authorization follows the application's log search (#488): authorized
in a short transaction, the store read with no lock or transaction held,
then authorized again before any line leaves.

**Web**
- The "will appear here" note on the deployment page is replaced by a
**Build output** section under the timeline. It follows the "Full log"
block of design screen 15: a title, "Rootless BuildKit" on the right, a
mono block of at most 420 px, each line prefixed with its time.
- While the deployment runs, the section reads again every 3 s, and
twice more once it has finished. Each read starts 3 s before the last
line, because batches of one build may reach the store side by side. A
line read twice shows once.
- The view follows the end unless the reader scrolled up. It keeps the
last 8192 lines, as many as the agent holds for one build, and says so
when it drops older ones.
- An image deployment promises no build output. A deployment that runs a
release command says its output is not collected yet.
- The page says when the installation keeps no logs, and when the read
fails, with a Retry button.
- French translations added.

**Docs**: SPEC section 12 describes the route and the live view; section
8 points the timeline at it. The route/role matrix is regenerated.

## Why

#215 builds now run (#533, #537) and their output reaches VictoriaLogs
(#534), but nobody could see it. Without that, a failed build is a
failed deployment with no reason anyone can read.

## How it was tested

- Unit tests:
- the LogsQL query: exact time, injection attempts in each identifier,
records that are not build lines;
- the service: margin before the start, a deployment of another
application, no store, access withdrawn while the store answers;
  - the line merge: repeats, order, the 8192 bound;
- the page: live reads with `from`, a line read twice, reads stop after
the deployment finished, no log store, a read failure then Retry.
- Integration with PostgreSQL (`build-output-http.integration.spec.ts`):
  - viewer access, the exact query, `from` to the nanosecond;
  - a `from` with no offset, or in the future, is refused;
- an outsider, and a deployment under another application, get 404 and
the store is never asked.
- Mutation check: dropping the application filter from the SQL fails
that test.
- Chromium against the production build (`github.browser.spec.ts`): a
Git application with a Dockerfile is deployed on an enrolled server, and
its page shows the build output a fake log store answers, read again
while it runs. Checked under the production CSP and axe.
- Locally: web 404/404 unit tests, API 973/973 unit tests. Integration
469 passed; the only failures are the known local ones (PostgreSQL 18's
23001 ×3, and the metrics, S3 and Distribution suites, which need a
container runtime).

The diff is about 1100 lines excluding generated code, about half of it
tests.

## Security considerations

- Build lines are redacted by the agent before they leave the server
(#534): secret values, the Git token and the registry password. This
route only reads what was stored.
- Identifiers in the LogsQL query are validated as UUIDs. `from` must be
RFC 3339 with an offset, and enters the query only through the strict
nine-digit form, so no user text reaches the query.
- Access is `environment.read`, the same as application logs. Access is
checked again after the store answers, so a reader who loses access
during the read gets nothing.

## UI validation

Screenshots (desktop and mobile, English and French) were shared with
the maintainer. This PR waits for their validation before merging.

---------

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.

1 participant