Repository navigation
app-nextjs: a publish script, and plx-ci image, the image helper behind it - #73
Open
davidjalbers wants to merge 10 commits into
Open
davidjalbers wants to merge 10 commits into
davidjalbers wants to merge 10 commits into
Conversation
…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]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An app from
app-nextjspublishes its own image: itspublishscript isplx-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 inapps/<app>after the build, reads the build ID from.next/standalone/apps/<app>/.next/BUILD_IDand refuses an output without one; no Turbo dry run, no restore from a cache.imageRefandimagePrefixof@plexus-ms/lib:<prefix>/<app>:build-<hash>and<prefix>/<app>:<commit>, the commit being the checkout's HEAD.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.BUILDKIT_HOST's BuildKit service where the job has one, else through the machine's own Docker.plx-ci image --prunedis the second mode, for an app whose own Dockerfile builds it from aturbo prunecontext; the server-actions key and the npmrc reach that build as BuildKit secrets, as before.app-nextjsrenders"publish": "plx-ci image", and its marker names the script andmise :publish <app>.repo-turbo's Turbo taskpublishgetspassThroughEnv: ["IMAGE_PREFIX", "NPM_CONFIG_USERCONFIG"], in a commit of its own with a test (the one edit toturbo.json.jinjathe issue's brief allowed).plx-ci's ownimageNameandimagePrefixare gone;plan,display-versionsandpublishtake lib's.The headers of
core/image.ts(the steps, the two modes, what the manifest holds),core/build.tsandcommands/image.ts(what it reads from the environment) state the rest.Decisions this pull request made that the issue did not
plx-ci image, with--prunedfor the second mode, andplx-ci publishkeeps working unchanged until the workflows are rewritten (_publish-deploy.ymlandnewborns/pipeline.test.tsstill call it). The list of what goes with it is below.imagetools inspectandimagetools create --prefer-index=falsea repo job needs no crane on a forge runner. Tried againstregistry:2: a missing tag answersERROR: <ref>: not found, exit 1;--prefer-index=falsekeeps the digest, the default wraps the manifest in an index. A missing tag on ghcr.io is not tried; the old crane check matchedMANIFEST_UNKNOWN|NAME_UNKNOWN|404, and buildx printsnot foundfor a 404.git rev-parse HEAD), asplx deploytakes it, notGITHUB_SHA..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_IDbeside it is absent or stale after a replay. In the--prunedmode it is Next's.next/BUILD_ID, which the root'sbuildoutputs hold.NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, which the workflows andplx-ci setup's hand-over use; the helper needs it in the--prunedmode alone.envorpassThroughEnvfor the key,GITHUB_*orDOCKER_CONFIG: Turbo 2.11.13 passesGITHUB_*,DOCKER_*,BUILDKIT_*,NEXT_*andHOMEto every task by its own list. Seen by running apublishscript under Turbo with these set (it sawBUILDKIT_HOST,DOCKER_CONFIG,GITHUB_REPOSITORY,GITHUB_SHA,NEXT_SERVER_ACTIONS_ENCRYPTION_KEY, and notIMAGE_PREFIXorNPM_CONFIG_USERCONFIG), and in the list of variables the binary carries.packageName,turboOfandImageContextmoved fromcore/plan.tstocore/build.ts, which keeps using them after the plan goes; the restore of the output moved frombuild.tsintocore/publish.ts, which goes withplx-ci publish.For the issue that rewrites the workflows
The step is
mise run publish; each app's script runsplx-ci image(orplx-ci image --pruned) inapps/<app>.It reads
IMAGE_PREFIX, elseGITHUB_REPOSITORY;BUILDKIT_HOST; Docker's login fromDOCKER_CONFIG(else~/.docker); and in--prunedmodeNEXT_SERVER_ACTIONS_ENCRYPTION_KEYandNPM_CONFIG_USERCONFIG. It needs git and Docker's client with buildx, and no crane.What it deletes with
plx-ci publishand the plan:packages/cli-ci/src/commands/publish.ts,core/publish.ts,core/publish.test.ts, andpublishincommands/index.tsandprogram.test.ts.craneDigestandcraneNotFoundincore/registry.ts(withcore/plan.tsand, by the display-versions issue,core/displayVersions.ts, its last users), and the tests ofregistry.test.tsthat hold them.ImageContext's use by the plan (imageContextOf);ImageContext,packageNameandturboOfstay inbuild.ts.cranein the runner image'smise.tomlonce 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,packageNameandturboOfintocore/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 inregistry.ts.What the workflows' issue then deletes with
plx-ci publishis 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.plxandplx-cifrom a local npm registry: a new app repo with one app,mise run build web, thenmise run publish webagainstregistry:2on loopback pushedbuild-<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 withoutBUILD_IDwas refused; the manifest is one OCI image manifest, linux/amd64, a config and seven layers, no index and no attestations.🤖 Generated with Claude Code