Skip to content

feat(devcontainer): publish app port to host for CLI workflows#426

Merged
jakehobbs merged 1 commit into
mainfrom
jakehobbs/devcontainer-port-forwarding
May 30, 2026
Merged

feat(devcontainer): publish app port to host for CLI workflows#426
jakehobbs merged 1 commit into
mainfrom
jakehobbs/devcontainer-port-forwarding

Conversation

@jakehobbs
Copy link
Copy Markdown
Member

@jakehobbs jakehobbs commented May 30, 2026

The devcontainer CLI ignores devcontainer.json's forwardPorts (a VS Code editor feature), so the Go server wasn't reachable from the host when running via devcontainer exec; this publishes the container port at the Docker layer in the generated workspace compose file. The Makefile now parameterizes the server PORT (default unchanged at 8080) so each checkout can listen on a distinct port, and write-workspace-compose.sh publishes host→container 1:1 when a port is pinned so the logged port matches the reachable host port. A new conductor.json adds setup/run scripts that bring up the devcontainer, install deps, and run the app on a per-workspace port. Default local/VS Code behavior is unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Configurable port support for running multiple parallel development environments
    • Enhanced devcontainer workspace setup with automatic port mapping
    • Environment variable support for custom port configuration
  • Chores

    • Updated build system and development configuration for improved parallel development workflows

Review Change Stack

The devcontainer CLI ignores devcontainer.json's forwardPorts (a VS Code
editor feature), so the Go server wasn't reachable from the host when
running via `devcontainer exec`. Publish the container port at the Docker
layer in the generated workspace compose file, and parameterize the
server PORT in the Makefile (default unchanged at 8080) so each checkout
can use a distinct port. Add conductor.json setup/run scripts that bring
up the devcontainer, install deps, and run the app on a per-workspace
port.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jakehobbs jakehobbs requested a review from alexsapps as a code owner May 30, 2026 19:53
Copilot AI review requested due to automatic review settings May 30, 2026 19:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR enables configurable and stable port allocation in the development environment, allowing parallel workspaces to operate independently. The Docker Compose setup computes deterministic host ports from workspace names or explicit configuration, while Makefile and Conductor scripts integrate those ports into the build and run workflows.

Changes

Port Configuration and Wiring

Layer / File(s) Summary
Docker Compose port computation and publishing
.devcontainer/write-workspace-compose.sh
Workspace name is sanitized for DNS safety, then a stable host port is selected from ADB_HOST_PORT environment variable or derived from a hash of the workspace name. The generated compose.workspace.yaml includes a ports mapping to expose the Go server on the host.
Makefile and Conductor script integration
Makefile, conductor.json
Makefile exports a configurable PORT variable (default 8080) and updates run_all to use http://localhost:$(PORT). conductor.json adds setup and run scripts that propagate ADB_HOST_PORT=$CONDUCTOR_PORT to the devcontainer, run the build and startup targets, and clean up competing processes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through ports with care,
Stabilizing each workspace pair,
No collision, no strife,
Each dev gets their own life! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making the app port accessible from the host machine for CLI-based devcontainer workflows through published ports in the compose file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jakehobbs/devcontainer-port-forwarding

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a host port publish for the devcontainer-managed Go server so the app is reachable from the host when started via devcontainer exec (the CLI ignores forwardPorts). Parameterizes the server PORT in the Makefile and introduces a conductor.json to orchestrate per-workspace devcontainer setup/run with distinct ports.

Changes:

  • Makefile: introduces PORT ?= 8080 (exported) and uses it in NEXT_PUBLIC_API_BASE_URL.
  • .devcontainer/write-workspace-compose.sh: publishes a host port (from ADB_HOST_PORT or a hash of the workspace name) to the container, 1:1 when pinned.
  • New conductor.json: setup/run scripts that bring up the devcontainer and run the app on $CONDUCTOR_PORT.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Makefile Adds parameterized PORT variable and threads it into NEXT_PUBLIC_API_BASE_URL for run_all.
.devcontainer/write-workspace-compose.sh Emits a ports: mapping in the generated workspace compose, using ADB_HOST_PORT (1:1) or a hashed fallback.
conductor.json New Conductor config wiring devcontainer up/exec with ADB_HOST_PORT/PORT set to $CONDUCTOR_PORT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jakehobbs jakehobbs merged commit a35b299 into main May 30, 2026
2 of 3 checks passed
@jakehobbs jakehobbs deleted the jakehobbs/devcontainer-port-forwarding branch May 30, 2026 19:56
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.

2 participants