feat(cli): optional Apple container runtime for local generation - #17541
feat(cli): optional Apple container runtime for local generation#17541devin-ai-integration[bot] wants to merge 5 commits into
container runtime for local generation#17541Conversation
Add Apple's `container` runtime as an accepted value for the `--container-engine` flag (cli-v2) and `--runner` flag (legacy CLI), alongside `docker` and `podman`. Apple's container CLI mirrors Docker's command structure (run/pull/exec/cp/rm), so no per-command branching is needed; the existing subprocess invocations work as-is. The "not installed" error now resolves an engine-specific install URL via an exhaustive switch instead of a docker/podman-only ternary, so container users are pointed at the right place. Closes #16854 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Apple's container CLI namespaces image commands and has no run --pull flag, so explicit pulls use container image pull and always-pull is satisfied by pulling before run. Failures under the Apple runtime hint at container system start. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
AI Review Summary
Adds Apple container as an opt-in runtime, centralizes the runner list in CONTAINER_RUNNERS, and fixes Apple-specific pull semantics (container image pull, no --pull on run). The pull-path fix and test coverage look right. Two concerns: a likely missing/implicit dependency plus value-import of a type in generator-cli, and the Apple "start the runtime" hint being appended to every non-zero exit (including ordinary generator failures). Also worth confirming other Docker-only run flags (--platform, --network) are actually accepted by Apple's CLI, since that was the root cause the PR set out to fix.
- 🟡 2 warning(s)
- 🔵 1 suggestion(s)
To request another review, comment /ai-review on this pull request.
| @@ -1,3 +1,5 @@ | |||
| import { ContainerRunner } from "@fern-api/core-utils"; | |||
There was a problem hiding this comment.
🟡 warning
This is a type-only usage — under verbatimModuleSyntax a value import here emits a runtime import from a module this file otherwise doesn't need. Also double-check @fern-api/core-utils is declared in packages/generator-cli/package.json; no package.json change is in this PR.
| import { ContainerRunner } from "@fern-api/core-utils"; | |
| import type { ContainerRunner } from "@fern-api/core-utils"; |
| throw new Error( | ||
| `Container exited with code ${exitCode}.\n${stdout}\n${stderr}` + | ||
| (containerRunner === "container" ? `\n${APPLE_CONTAINER_SERVICE_HINT}` : "") | ||
| ); |
There was a problem hiding this comment.
🔵 suggestion
This appends the "start the runtime with container system start" hint to every non-zero exit, including a generator that legitimately failed with exit code 1. That's misleading noise for the common case. Consider gating it on a signal that the runtime isn't up (e.g. stderr matching connection/daemon errors) — same for the startContainer variant below.
| // Apple's `container run` has no `--pull` option, so an always-pull request is | ||
| // satisfied by pulling explicitly beforehand. | ||
| const pullBeforeRun = pull && runner === "container"; | ||
| if (pullBeforeRun) { | ||
| await pullImage(imageName, runner, signal); | ||
| } |
There was a problem hiding this comment.
🟡 warning
The PR premise is that Apple's CLI isn't Docker-flag-compatible — --pull is fixed here, but the same run invocation still passes Docker-shaped flags (--platform, and --network where used). Apple's container run exposes --arch/--os rather than --platform, so pull: true paths are fixed but platform paths will still fail. Worth verifying/translating those too, or at least documenting the limitation.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Description
Refs #16854. Supersedes #16856 (community PR by @davidbarratt, whose commits are included here) — I couldn't push to that fork branch (403), so this branch carries their work plus review fixes.
Docker stays the default and recommended runtime; Apple's
containeris opt-in via--container-engine container/--runner container.The community PR assumed Apple's CLI is command-compatible with Docker, but it isn't for image pulls, so both pull paths would have failed:
pullImage()rancontainer pull <img>; Apple namespaces it ascontainer image pull <img>(hit by the missing-image retry inrunContainer).pull: truepassedrun --pull always, which Apple'scontainer runhas no flag for — this is reached in production byLocalParserRunner(pull: isDefaultImage).Changes Made
runDocker.ts:pullImageuses["image", "pull", img]forcontainer,["pull", img]otherwise; an always-pull request undercontainerbecomes an explicit pull beforeruninstead of--pull always. Docker/Podman behavior unchanged.runDocker.ts: run/start failures undercontainerappend a hint to start the runtime withcontainer system start.CONTAINER_RUNNERSin@fern-api/core-utilsis now the single source of the runner values;ContainerRunnerderives from it and all three yargschoicesreuse it, so flags can't drift from the union.containeras optional, with Docker as the default/recommended runtime.container image pullon explicit pull and on missing-image retry, no--pullpassed tocontainer run) plus a Docker retry case; fixedlastRunnerBinary()to actually read the last call and swappedCONSOLE_LOGGER→NOOP_LOGGER.Testing
pnpm turbo run compilefor@fern-api/core-utils,@fern-api/docker-utils,@fern-api/cli,@fern-api/cli-v2: 94/94 tasks successful.pnpm lint:biome,biome format, and prettier on the changelog: clean.Link to Devin session: https://app.devin.ai/sessions/6938948da2234246b7734659a978956b