Skip to content

dx: Namespaced local docker#1119

Draft
Custard7 wants to merge 9 commits intomainfrom
namespaced-local-docker
Draft

dx: Namespaced local docker#1119
Custard7 wants to merge 9 commits intomainfrom
namespaced-local-docker

Conversation

@Custard7
Copy link
Copy Markdown
Collaborator

@Custard7 Custard7 commented Mar 23, 2026

Running local dev services (compose-local.yaml) and e2e tests (tests/e2e/compose.yaml) simultaneously causes port conflicts — both stacks bind to the same host ports (4000, 4100, 4200, etc.). Additionally, Docker Compose container names collide since they're hardcoded.

Solution

Introduce a PORT_OFFSET mechanism that shifts all host port bindings by a configurable integer, and derive Compose project names from the git branch to isolate container namespaces.

Default behavior is unchanged — with PORT_OFFSET=0 (the default), all ports resolve to their original values.

What changed

New files:

  • scripts/dc.sh — Docker Compose wrapper that computes a project name from the git branch (or LC_PROJECT), exports offset host ports, and delegates to docker compose -p <project>. Prints a port table when offset is non-zero.
  • tests/e2e/tests/helpers/ports.ts — Centralized PORTS and URLS constants for all e2e test code. Reads PORT_OFFSET from the environment at module load.
  • tests/e2e/.env.example — Documents available environment variables.

Compose files parameterized:

  • apps/learn-card-app/compose-local.yaml — Removed container_name directives; all host ports now use ${VAR:-default} substitution.
  • tests/e2e/compose.yaml — Same treatment.

E2E tests updated (25 files):

  • All hardcoded localhost:PORT URLs replaced with imports from ports.ts (URLS.brainApi, URLS.cloudTrpc, PORTS.brain, etc.)
  • global-setup.ts now invokes dc.sh for managed Docker start/stop.
  • db-utils.ts uses PORTS for database connections (Neo4j, Redis, MongoDB, Postgres).
  • Every spec file (health, boosts, inbox, unified-send, api-keys, app-dids, app-store-credentials, consentflow, signing-authorities, credential-activity, init, xapi, qr-login, recovery-email, sss-keys, upgrade-contact-method, DCC interop) migrated.

Package scripts:

  • apps/learn-card-app/package.jsondev:services and related scripts use dc.sh.
  • tests/e2e/package.json — logs script uses dc.sh.

Usage

# Default — no change in behavior
pnpm run dev:services

# Run a second stack on offset ports (brain=4100, cloud=4200, ...)
PORT_OFFSET=100 pnpm run dev:services

# E2E tests with offset
PORT_OFFSET=100 pnpm --filter @workspace/e2e-tests test:e2e

Notes

  • The only localhost:PORT strings left in test files are intentional fixture data (e.g., arbitrary signing authority endpoints, whitelist domain strings), not service connections.

Rovo Dev code review: Out of Rovo Dev credits
You've used all your Rovo Dev credits, so Rovo Dev can't review your pull requests.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 23, 2026

⚠️ No Changeset found

Latest commit: 21f34a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2026

Deploy Preview for staging-learncardapp ready!

Name Link
🔨 Latest commit 21f34a3
🔍 Latest deploy log https://app.netlify.com/projects/staging-learncardapp/deploys/69d7c5f040a19f000892f1cb
😎 Deploy Preview https://deploy-preview-1119--staging-learncardapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2026

Deploy Preview for app-store-1-basic-launchpad-app canceled.

Name Link
🔨 Latest commit 21f34a3
🔍 Latest deploy log https://app.netlify.com/projects/app-store-1-basic-launchpad-app/deploys/69d7c5f041079e000868071d

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2026

Deploy Preview for learncarddocs canceled.

Name Link
🔨 Latest commit 21f34a3
🔍 Latest deploy log https://app.netlify.com/projects/learncarddocs/deploys/69d7c5f0ae19830008d70972

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hey there! It looks like you modified code, but didn't update the documentation in /docs.

If this PR introduces new features, changes APIs, or modifies behavior that users or developers need to know about, please consider updating the docs.


🏄 Windsurf Tip

You can ask Windsurf to help:

"Analyze the changes in this PR and update the gitbook docs in /docs accordingly."

Windsurf will review your changes and suggest appropriate documentation updates based on what was modified.


📚 Documentation Guide
Change Type Doc Location
New feature/API docs/tutorials/ or docs/how-to-guides/
SDK/API changes docs/sdks/
New concepts docs/core-concepts/
App UI/UX flows docs/apps/ (LearnCard App, ScoutPass)
Internal patterns AGENTS.md

This is an automated reminder. If no docs are needed, feel free to ignore this message.

@Custard7
Copy link
Copy Markdown
Collaborator Author

@claude please review

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 23, 2026

Claude finished @Custard7's task —— View job


Code Review Complete

Todo List:

  • Fetch PR diff and file details
  • Review implementation for correctness and issues
  • Check against auto-approval hard-stop rules
  • Determine approval lane eligibility
  • Post comprehensive review with decision

Analysis: This PR introduces a PORT_OFFSET mechanism to enable running multiple Docker Compose stacks simultaneously without port conflicts. The implementation is clean and well-structured.

✅ Strengths

  • Excellent backward compatibility: Default PORT_OFFSET=0 preserves existing behavior
  • Comprehensive coverage: All 25+ E2E test files properly migrated to use centralized port configuration
  • Clean architecture: ports.ts helper centralizes all port/URL logic, eliminating hardcoded URLs
  • Robust script: dc.sh wrapper handles project naming, port computation, and provides helpful output
  • Good documentation: Clear .env.example and inline comments explain usage

⚠️ Auto-Approval Assessment

This PR requires manual review due to:

  1. Docker Compose file modifications (hard-stop rule) - Both apps/learn-card-app/compose-local.yaml and tests/e2e/compose.yaml are modified
  2. Cross-cutting infrastructure changes - Spans tooling, test infrastructure, and docker configuration
  3. New shell script with exec permissions - scripts/dc.sh executes docker compose commands

🔍 Technical Review

Scripts/Tooling (scripts/dc.sh):

  • Shell script follows good practices (set -euo pipefail)
  • Git branch sanitization logic is sound
  • Port computation is straightforward arithmetic
  • No security concerns identified

Test Infrastructure:

  • Centralized port configuration in tests/e2e/tests/helpers/ports.ts is well-designed
  • All E2E tests correctly migrated to use URLS and PORTS constants
  • Database connection strings properly parameterized
  • Health check URLs updated consistently

Docker Configuration:

  • Compose files properly use ${VAR:-default} substitution pattern
  • Container name removal enables multiple instances
  • Environment variable references are consistent
  • No hardcoded secrets or credentials detected

📝 Minor Suggestions

  • Consider adding validation in dc.sh to check if computed ports are already in use
  • The port table output could include LRS (8080) for completeness
  • A quick reference in CLAUDE.md about the new PORT_OFFSET mechanism would be helpful

Decision: Manual review required due to Docker infrastructure changes, but implementation is solid and follows good practices.


Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Code Review Complete

Analysis: This PR introduces a mechanism to enable running multiple Docker Compose stacks simultaneously without port conflicts. The implementation is clean and well-structured.

✅ Strengths:

  • Excellent backward compatibility: Default preserves existing behavior
  • Comprehensive coverage: All 25+ E2E test files properly migrated to use centralized port configuration
  • Clean architecture: helper centralizes all port/URL logic, eliminating hardcoded URLs
  • Robust script: wrapper handles project naming, port computation, and provides helpful output
  • Good documentation: Clear and inline comments explain usage

⚠️ Auto-Approval Assessment:

This PR requires manual review due to:

  1. Docker Compose file modifications (hard-stop rule) - Both and are modified
  2. Cross-cutting infrastructure changes - Spans tooling, test infrastructure, and docker configuration
  3. New shell script with exec permissions - Usage: docker compose [OPTIONS] COMMAND

Define and run multi-container applications with Docker

Options:
--all-resources Include all resources, even those not
used by services
--ansi string Control when to print ANSI control
characters ("never"|"always"|"auto")
(default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for
unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto,
tty, plain, json, quiet)
--project-directory string Specify an alternate working directory
(default: the path of the, first
specified, Compose file)
-p, --project-name string Project name

Management Commands:
bridge Convert compose files into another model

Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
publish Publish compose application
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
volumes List volumes
wait Block until containers of all (or specified) services stop.
watch Watch build context for service and rebuild/refresh containers when files are updated

Run 'docker compose COMMAND --help' for more information on a command. executes docker compose commands

🔍 Technical Review:

**Scripts/Tooling (Usage: docker compose [OPTIONS] COMMAND

Define and run multi-container applications with Docker

Options:
--all-resources Include all resources, even those not
used by services
--ansi string Control when to print ANSI control
characters ("never"|"always"|"auto")
(default "auto")
--compatibility Run compose in backward compatibility mode
--dry-run Execute command in dry run mode
--env-file stringArray Specify an alternate environment file
-f, --file stringArray Compose configuration files
--parallel int Control max parallelism, -1 for
unlimited (default -1)
--profile stringArray Specify a profile to enable
--progress string Set type of progress output (auto,
tty, plain, json, quiet)
--project-directory string Specify an alternate working directory
(default: the path of the, first
specified, Compose file)
-p, --project-name string Project name

Management Commands:
bridge Convert compose files into another model

Commands:
attach Attach local standard input, output, and error streams to a service's running container
build Build or rebuild services
commit Create a new image from a service container's changes
config Parse, resolve and render compose file in canonical format
cp Copy files/folders between a service container and the local filesystem
create Creates containers for a service
down Stop and remove containers, networks
events Receive real time events from containers
exec Execute a command in a running container
export Export a service container's filesystem as a tar archive
images List images used by the created containers
kill Force stop service containers
logs View output from containers
ls List running compose projects
pause Pause services
port Print the public port for a port binding
ps List containers
publish Publish compose application
pull Pull service images
push Push service images
restart Restart service containers
rm Removes stopped service containers
run Run a one-off command on a service
scale Scale services
start Start services
stats Display a live stream of container(s) resource usage statistics
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker Compose version information
volumes List volumes
wait Block until containers of all (or specified) services stop.
watch Watch build context for service and rebuild/refresh containers when files are updated

Run 'docker compose COMMAND --help' for more information on a command.):**

  • Shell script follows good practices ()
  • Git branch sanitization logic is sound
  • Port computation is straightforward arithmetic
  • No security concerns identified

Test Infrastructure:

  • Centralized port configuration in is well-designed
  • All E2E tests correctly migrated to use and constants
  • Database connection strings properly parameterized
  • Health check URLs updated consistently

Docker Configuration:

  • Compose files properly use substitution pattern
  • Container name removal enables multiple instances
  • Environment variable references are consistent
  • No hardcoded secrets or credentials detected

📝 Minor Suggestions:

  • Consider adding validation in to check if computed ports are already in use
  • The port table output could include LRS (8080) for completeness
  • A quick reference in CLAUDE.md about the new PORT_OFFSET mechanism would be helpful

Decision: Manual review required due to Docker infrastructure changes, but implementation is solid and follows good practices.

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

This PR requires manual review due to Docker infrastructure changes, but implementation is solid and follows good practices.

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