Skip to content

fix: make the local-docker deploy path usable (one --target + free-port selection)#4

Open
JoshuaBearup wants to merge 1 commit into
orlyjamie:mainfrom
JoshuaBearup:fix/local-docker-usable
Open

fix: make the local-docker deploy path usable (one --target + free-port selection)#4
JoshuaBearup wants to merge 1 commit into
orlyjamie:mainfrom
JoshuaBearup:fix/local-docker-usable

Conversation

@JoshuaBearup

Copy link
Copy Markdown

What

Two small fixes that make the existing local-docker target actually usable from the CLI.

1. polyrange one couldn't target local-docker

generator/deploy.mjs accepts --target=fly|local-docker, but cmdOne hardcoded --target=fly:

const args = ['generator/deploy.mjs', `--class=${cls}`, `--tier=${tier}`, '--target=fly']

So node polyrange.mjs one --class=… --target=local-docker silently still deployed to Fly. Fixed by threading --target (default fly) and --region through to the subprocess.

2. local-docker port had no collision check

The host port was chosen as 8000 + Math.floor(Math.random() * 1000) with no check that it's free. Under concurrent deploys (e.g. an eval fan-out) two cells can draw the same port and the second docker run -p fails with a port-in-use error. Replaced with an OS-assigned free ephemeral port on 127.0.0.1 via net.createServer().listen(0).

Testing

node -c clean on both files. Verified findFreePort() returns distinct usable ports on repeated calls, and that cmdOne now forwards flags.target instead of a literal. I did not run a full container deploy end-to-end here (no API key for the generation step in my environment), but both changes are in the deploy plumbing, independent of generation.

Note

I left the related "precheck requires flyctl even for a local-docker run" out of this PR — one doesn't run precheck, and eval/deploy are Fly-only today, so making precheck target-aware really belongs with a separate "local-docker eval" change rather than a bug fix. Happy to follow up on that if local-docker eval is on the roadmap.

Two fixes to the local-docker target, which deploy.mjs supports but the
CLI couldn't reach reliably:

1. `polyrange one` hardcoded `--target=fly`, so the single-class command
   could never deploy to local-docker even though `generator/deploy.mjs`
   accepts `--target=local-docker`. Thread `--target` (default fly) and
   `--region` through to the deploy subprocess.

2. local-docker picked its host port with `8000 + random(1000)` and no
   collision check, so concurrent deploys could choose the same port and
   the second `docker run -p` would fail. Ask the OS for a free ephemeral
   port on 127.0.0.1 instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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