Skip to content

fix(compose): forward published ports (#19) and accept -f before subcommand (#21)#22

Merged
us merged 2 commits into
mainfrom
fix/compose-ports-and-file-flags
Jun 12, 2026
Merged

fix(compose): forward published ports (#19) and accept -f before subcommand (#21)#22
us merged 2 commits into
mainfrom
fix/compose-ports-and-file-flags

Conversation

@us

@us us commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Fixes two independent, verified compose bugs. Plan was produced and adversarially reviewed via a multi-agent loop; both root causes confirmed against source.

#19compose up never forwards published ports (ECONNREFUSED)

buildRunArguments never emitted -p/--publish. Forwarding relied on a user-space PortProxy that only started when container inspect already reported an IP — but right after container run -d the guest IP is unassigned, so the proxy never started and the failure was swallowed by try?. Every published port returned ECONNREFUSED.

Fix: emit native -p host:container/proto (Apple's container CLI supports [host-ip:]host-port:container-port[/protocol], verified on 0.12.3) and stop relying on the proxy. portProxy.stop is retained on stop/remove to clean up proxies left by older versions. PortMapping.parse now also accepts ip:host:container and bare-container forms. Also fixes mocker run -p, which shared the same path.

#21compose -f a.yaml -f b.yaml pull → "Unknown option '-f'"

ComposeOptions is an @OptionGroup on each subcommand, so swift-argument-parser only accepts -f/-p after the subcommand token, while Docker places them before it. -f was also single-valued.

Fix: ComposeArgNormalizer relocates pre-subcommand -f/--file/-p/--project-name to after the subcommand (invoked from a custom MockerCLI.main before parsing); file: String?files: [String]; new ComposeFile.merge for ordered multi-file overlay (later overrides earlier; environment/labels field-merge). Flags after the subcommand and single-file usage are unchanged.

Verification

  • swift build + swift test: 99/99 pass (new unit tests for -p emission, port grammar, argv reordering, and multi-file merge).
  • E2E: mocker compose -f base.yaml -f dev.yaml config now works and correctly merges (overlay image wins, base ports preserved, env merged) — previously errored.
  • mocker compose does not forward published ports to host (ECONNREFUSED) #19 forwarding chain: reporter empirically confirmed native container run -p is host-reachable; unit test confirms mocker now emits exactly that.

Closes #19
Closes #21

us added 2 commits June 12, 2026 23:55
buildRunArguments never emitted -p/--publish; port forwarding relied on a
user-space PortProxy started only when `container inspect` already reported
an IP. Right after `container run -d` the guest IP is unassigned, so the
proxy never started and the error was swallowed by `try?` — every published
port returned ECONNREFUSED.

Emit native `-p host:container/proto` (Apple's container CLI supports it) and
drop the proxy start; portProxy.stop is kept on stop/remove to clean up any
proxies left by older versions. PortMapping.parse now also accepts the
ip:host:container and bare-container forms found in real compose files.

This fixes `mocker compose up` and `mocker run -p`, which shared the path.

Closes #19
`mocker compose -f a.yaml -f b.yaml pull` failed with "Unknown option '-f'":
ComposeOptions is an @OptionGroup on each subcommand, so swift-argument-parser
only accepts -f/-p after the subcommand token, while Docker places them before
it. -f was also single-valued, so multiple compose files were unsupported.

Add ComposeArgNormalizer to relocate pre-subcommand -f/--file/-p/--project-name
after the subcommand (invoked from a custom MockerCLI.main before parsing),
change file: String? to files: [String], and add ComposeFile.merge for ordered
multi-file overlay (later files override earlier; environment/labels field-merge).
Flags after the subcommand and single-file usage keep working unchanged.

Closes #21
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.

mocker compose rejects valid options in the commandline mocker compose does not forward published ports to host (ECONNREFUSED)

1 participant