Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

8.9 KB
Raw Blame

TL;DR

mbuild publishes, verifies, and promotes the container artifacts declared by mstage.

mbuild reference

Infrastructure index · Deployment · Configuration

Run from apps/infra. Bootstrap the registry and sign in before commands that contact it. The image declaration includes api (with dashboard), proxy, otel-collector, registry-proxy, and secret-server. Release publishing builds the declared images. Deployment verification and release import honor an artifact's optional deployStages list and deployCloud provider. GCP dev, stage and prod require the Secret Server image. For a full GCP production rollout or rollback, select a published release that includes this image. Runner binaries use the separate runner commands.

Commands

npm run mbuild inspect -- --stage dev
npm run mbuild publish -- --tag <full-commit-sha> --stage dev
npm run mbuild verify -- --tag <full-commit-sha> --stage dev
npm run mbuild promote -- --tag <full-commit-sha> --from dev --to prod
Option Effect
--artifact api Select one declared artifact; omission selects all
--version vX.Y.Z Address the release build vX.Y.Z-<sha> instead of the commit build <sha>
--stage Select publication/verification destination
--from, --to Select promotion source and destination

inspect prints registry kind, region, repository and artifact names without resolving cloud identity. publish builds from the current checkout; the tag is an identity, not a checkout command. Use the deployment workflow to resolve a ref and prepare the matching source tree. verify prints artifact=address results and does not build missing images.

Registry and promotion boundaries

Stage home Registry Coordinates
GCP Artifact Registry Declared project, region and repository
AWS ECR Account from credentials, declared region and repository

Release images in GHCR

GHCR publication runs in the publish job of mbuild-release on main, independently of dev/prod cloud credentials. Local operators dispatch the workflow; direct GHCR CLI writes outside that context are refused before registry access.

gh workflow run mbuild-release.yml --repo boxlite-ai/boxlite --ref main -f command=publish -f tag=vX.Y.Z -f build-only=true
npm run mbuild verify -- --tag <full-commit-sha> --version vX.Y.Z --ghcr boxlite-ai/boxlite
npm run mbuild import-release -- --tag <full-commit-sha> --version vX.Y.Z --ghcr boxlite-ai/boxlite --stage prod

This publication-only example skips deployment, E2E, and Slack reporting. Omit build-only for the default release pipeline: check release assets, deploy and validate dev, report E2E to Slack, then deploy the approved tag to prod within the release run.

The address is ghcr.io/<owner>/<repository>/<artifact>:vX.Y.Z-<full-sha>. Artifact names and tags match Artifact Registry's layout; GHCR has no stage suffix. Set GHCR_USERNAME and GHCR_TOKEN, or use GITHUB_ACTOR and GH_TOKEN in Actions. Publishing needs package write access; verification/import needs package read access. GHCR publication and GHCR verification without a target stage read the artifact declaration without a cloud stage file. For verify --ghcr --stage <name>, declare that stage in the mstage config. Its cloud and name select the deployment images to verify in GHCR. For publication, use MSTAGE_ENV_CONFIG to select the release source's declaration and build context. import-release imports and verifies the artifacts required by its current declaration; an older release lacking a required artifact fails this import.

Publication audits dependencies and reuses existing images without overwriting them. Workflow concurrency serializes the full publication interval for one release; an atomic lock under RUNNER_TEMP prevents competing CLI processes inside a job. Different artifacts remain parallel, and locks are released after failed commands. These guarantees cover the supported publisher; a package writer can still bypass it and push directly. Retry a partial publication to build only missing artifacts; success requires every selected image to exist. Import checks all source manifests before destination writes, copies immutable source digests with Docker Buildx, refuses conflicting destination images, and verifies the copied manifest digest. imagetools create --prefer-index=false preserves manifest bytes without the local Docker image store. Artifact Registry lookups match exact tags, including when a similarly named backup tag exists. Only single-platform OCI and Docker schema 2 manifests are supported; indexes are refused. Manifest Content-Type is authoritative; an embedded media type may be omitted but must agree when present. GHCR publication pushes linux/amd64 explicitly and requires Docker API 1.46 or later. GHCR image scanning runs after import, using the receiving stage's existing scan policy. Artifact Analysis discovery must report completion before vulnerability findings are accepted. Pending or missing discovery waits up to the configured timeout; failed or unsupported scans stop immediately. Confirmed missing manifests exit 66; authentication, transport and other registry errors fail separately.

Stage-to-stage promotion copies existing image bytes within one cloud registry kind. Cross-cloud promotion is refused. When no artifact is specified, the destination stage's cloud and name determine which images to promote. The caller needs source read and destination write access; promoteFrom lets bootstrap prepare those permissions. On AWS, the current CLI uses one resolved account for both registry addresses.

Image publication and the stage's scan policy are separate checks. Already-published artifacts are verified instead of blindly overwritten. Release images carry a version-qualified address, so a commit build is not interchangeable with the release build from the same SHA.

Exit codes

Code Meaning Response
0 Requested operation succeeded Continue to the next deployment check
65 Dependency audit failed or could not complete Resolve the reported cause before rerunning
66 Required artifact is absent Publish or promote the intended artifact
78 Scan policy refused the artifact Resolve the finding or review the policy
Other nonzero Command, authentication, network or input failure Read the error; do not treat it as absence

Dependency audit failures

publish audits production dependencies before the first image build. Both publication workflows stop immediately on exit 65, including audit service or registry errors; the audit's stdout and stderr remain in the failure message. Image scan refusals (78) also stop immediately, while other publication failures retain their retry policy. An already-published artifact needs no build or audit.

For this repository, reproduce the gate from apps/ with:

corepack yarn npm audit --severity high --environment production

From the repository root, make audit:apps runs the same gate without installing dependencies. Release version PRs run it through the title-selected preflight.

Upgrade affected dependencies and commit both package.json and yarn.lock before rerunning publication. If the audit could not reach its registry, resolve connectivity and rerun deliberately; the workflow will not retry the failed audit automatically.

The API, proxy, collector and registry-proxy publications share this apps/ audit; a vulnerable workspace dependency can block all four before any image is built. The workspace requires ws ^8.23.0 and uses a Yarn resolution to upgrade copies pinned by transitive dependencies, including Engine.IO and module federation. This covers GHSA-37g9-w4hg-h9qr, which affects ws >=8.0.0 <8.23.0. Remove the resolution only when the direct and transitive requirements all select patched versions; check corepack yarn why ws and regenerate the lockfile before rerunning the audit.

Implementation and verification

The CLI is bin/mbuild.ts. Addressing lives in src/address.ts, configuration in src/config.ts, and publication in src/publish.ts. mdeploy-all invokes the shared image action inside its approved image preparation leg, parallel to Runner preparation; the reusable mbuild workflow wraps the same steps. Release publication uses mbuild-release.

Run make test:apps:mbuild for image tooling typechecks and tests, or make test:apps:infra for the complete infrastructure suite, from the repository root.