Skip to content

app-nextjs: a publish script, and plx-ci image, the image helper behind it - #73

Open
davidjalbers wants to merge 10 commits into
plain-pipelinefrom
davidjalbers/plx-225-app-nextjs-a-publish-script-and-the
Open

davidjalbers wants to merge 10 commits into
plain-pipelinefrom
davidjalbers/plx-225-app-nextjs-a-publish-script-and-the

Conversation

@davidjalbers

Copy link
Copy Markdown
Contributor

An app from app-nextjs publishes its own image: its publish script is plx-ci image, a helper that finds or makes the image for the build output on disk (Decisions § 3.1 to § 3.9 of the project Plain pipeline).

What it does

  • plx-ci image, run in apps/<app> after the build, reads the build ID from .next/standalone/apps/<app>/.next/BUILD_ID and refuses an output without one; no Turbo dry run, no restore from a cache.
  • It names the image with imageRef and imagePrefix of @plexus-ms/lib: <prefix>/<app>:build-<hash> and <prefix>/<app>:<commit>, the commit being the checkout's HEAD.
  • Where the registry holds build-<hash>, it adds the commit's tag (docker buildx imagetools create --prefer-index=false, which copies the manifest as it is) and builds nothing.
  • Where it does not, it builds from the output directory with the app's Dockerfile for linux/amd64 and pushes both tags: through BUILDKIT_HOST's BuildKit service where the job has one, else through the machine's own Docker.
  • A machine other than Linux x64 is refused, in one line, before it builds from an output.
  • plx-ci image --pruned is the second mode, for an app whose own Dockerfile builds it from a turbo prune context; the server-actions key and the npmrc reach that build as BuildKit secrets, as before.
  • app-nextjs renders "publish": "plx-ci image", and its marker names the script and mise :publish <app>.
  • repo-turbo's Turbo task publish gets passThroughEnv: ["IMAGE_PREFIX", "NPM_CONFIG_USERCONFIG"], in a commit of its own with a test (the one edit to turbo.json.jinja the issue's brief allowed).
  • plx-ci's own imageName and imagePrefix are gone; plan, display-versions and publish take lib's.

The headers of core/image.ts (the steps, the two modes, what the manifest holds), core/build.ts and commands/image.ts (what it reads from the environment) state the rest.

Decisions this pull request made that the issue did not

  • The command is plx-ci image, with --pruned for the second mode, and plx-ci publish keeps working unchanged until the workflows are rewritten (_publish-deploy.yml and newborns/pipeline.test.ts still call it). The list of what goes with it is below.
  • The registry is asked with Docker's buildx, not crane. The helper needs Docker's client with buildx to build anyway; with imagetools inspect and imagetools create --prefer-index=false a repo job needs no crane on a forge runner. Tried against registry:2: a missing tag answers ERROR: <ref>: not found, exit 1; --prefer-index=false keeps the digest, the default wraps the manifest in an index. A missing tag on ghcr.io is not tried; the old crane check matched MANIFEST_UNKNOWN|NAME_UNKNOWN|404, and buildx prints not found for a 404.
  • The commit is the checkout's HEAD (git rev-parse HEAD), as plx deploy takes it, not GITHUB_SHA.
  • The build ID is read inside the output (.next/standalone/apps/<app>/.next/BUILD_ID), where the Dockerfile starts the app: app-nextjs's Turbo task caches only .next/standalone/**, so the .next/BUILD_ID beside it is absent or stale after a replay. In the --pruned mode it is Next's .next/BUILD_ID, which the root's build outputs hold.
  • The platform check applies to the output mode only, and only before a build: a pruned build makes the image inside Docker for linux/amd64, and tagging an image that exists builds nothing.
  • The server-actions key keeps the name NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, which the workflows and plx-ci setup's hand-over use; the helper needs it in the --pruned mode alone.
  • No env or passThroughEnv for the key, GITHUB_* or DOCKER_CONFIG: Turbo 2.11.13 passes GITHUB_*, DOCKER_*, BUILDKIT_*, NEXT_* and HOME to every task by its own list. Seen by running a publish script under Turbo with these set (it saw BUILDKIT_HOST, DOCKER_CONFIG, GITHUB_REPOSITORY, GITHUB_SHA, NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, and not IMAGE_PREFIX or NPM_CONFIG_USERCONFIG), and in the list of variables the binary carries.
  • packageName, turboOf and ImageContext moved from core/plan.ts to core/build.ts, which keeps using them after the plan goes; the restore of the output moved from build.ts into core/publish.ts, which goes with plx-ci publish.

For the issue that rewrites the workflows

The step is mise run publish; each app's script runs plx-ci image (or plx-ci image --pruned) in apps/<app>.
It reads IMAGE_PREFIX, else GITHUB_REPOSITORY; BUILDKIT_HOST; Docker's login from DOCKER_CONFIG (else ~/.docker); and in --pruned mode NEXT_SERVER_ACTIONS_ENCRYPTION_KEY and NPM_CONFIG_USERCONFIG. It needs git and Docker's client with buildx, and no crane.

What it deletes with plx-ci publish and the plan:

  • packages/cli-ci/src/commands/publish.ts, core/publish.ts, core/publish.test.ts, and publish in commands/index.ts and program.test.ts.
  • craneDigest and craneNotFound in core/registry.ts (with core/plan.ts and, by the display-versions issue, core/displayVersions.ts, its last users), and the tests of registry.test.ts that hold them.
  • ImageContext's use by the plan (imageContextOf); ImageContext, packageName and turboOf stay in build.ts.
  • The crane install steps of the workflows, and crane in the runner image's mise.toml once nothing else uses it.

Size

+811 −192 in 22 files: tests and their fakes +431 −8, the rest +380 −184.
About 75 of the added lines are moves (the restore into core/publish.ts, packageName and turboOf into core/build.ts).
The additions that stay are the helper (core/image.ts, commands/image.ts, 165 lines, half of them their headers, which the issue asks for) and the buildx lookup in registry.ts.
What the workflows' issue then deletes with plx-ci publish is 407 lines in those three files, their tests included, before the crane lookups and the plan.

Verified

  • TURBO_FORCE=true mise run test: 7 of 7 tasks, exit 0.
  • mise run e2e: 101 of 101, exit 0.
  • By hand, outside the tests, with this branch's plx and plx-ci from a local npm registry: a new app repo with one app, mise run build web, then mise run publish web against registry:2 on loopback pushed build-<hash> and the commit's tag to one digest; after an empty commit it only added the new commit's tag (imagetools create, no build); an output without BUILD_ID was refused; the manifest is one OCI image manifest, linux/amd64, a config and seven layers, no index and no attestations.

🤖 Generated with Claude Code

davidjalbers and others added 10 commits December 2, 2026 04:27
…CONFIG through Turbo (PLX-225)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ough Turbo's strict environment

Turbo 2.11.13 passes GITHUB_*, DOCKER_*, BUILDKIT_*, NEXT_* and HOME to a task by its own list (seen by running a
publish script under Turbo, and in the list the binary carries); IMAGE_PREFIX and NPM_CONFIG_USERCONFIG it hides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t, against a fake builder and registry (PLX-225)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…arameter does not replace

The test passed undefined to a parameter whose default is the hash, so its checkout held a BUILD_ID after all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…isk, for the checkout's commit

The helper an app's publish script runs, in apps/<app> after its build: the build ID the output holds names
build-<hash>; where the registry holds it, the commit's tag is added with buildx imagetools, else the image is built
from the output (or, with --pruned, from a pruned context with the app's own Dockerfile) and pushed under both.
A machine other than Linux x64 is refused before it builds from an output. build.ts builds from the directory it is
handed; the restore of the old publish moves into core/publish.ts, which goes with that command, and packageName,
turboOf and ImageContext move from plan.ts to build.ts, which keeps using them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lexus-ms/lib (PLX-225)

What the removed test held, the prefix lower-cased and without its trailing slash, the tests of plx-ci image hold
through the command, with IMAGE_PREFIX registry.example/Acme/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…b alone

imageRef and imagePrefix of lib are the one statement of the naming rule; plx-ci's own imageName, imagePrefix and
ownerOf go, and plan, display-versions and publish take lib's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…once and then only tagging (PLX-225)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…blish-script-and-the

Both commands are listed, setup and image; ownerOf stays in commands/shared.ts, which setup reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@davidjalbers davidjalbers self-assigned this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant