Skip to content

feat: Multi-instance development stack with full isolation#265

Merged
betterclever merged 13 commits intomainfrom
feat/multi-instance-dev-stack
Feb 6, 2026
Merged

feat: Multi-instance development stack with full isolation#265
betterclever merged 13 commits intomainfrom
feat/multi-instance-dev-stack

Conversation

@betterclever
Copy link
Contributor

@betterclever betterclever commented Feb 4, 2026

Multi-instance development environment supporting 10 concurrent isolated instances (0-9).

Key Features

  • Kafka Connectivity Fix: Configured Redpanda with dual listeners (internal 9092 / external 19092) to resolve host connectivity issues.
  • Dynamic CORS Origin: Automatically supports all instance ports (5173, 5273, etc.) for cross-origin requests.
  • Parallel E2E Testing: Validated isolation and parallel execution of E2E tests across instances.
  • Robust Cleanup: Enhanced `just dev all clean` for bulk instance maintenance and synchronized infrastructure scripts.
  • Dynamic Port Offsets: Consistent port mapping (base_port + instance*100).
  • Full Isolation: Isolated Databases, Temporal namespaces, and Kafka topics per instance.

Usage

```bash
just dev 1 start # Start instance 1
just dev 1 stop # Stop instance 1
just dev all stop # Stop all instances
just dev 1 clean # Reset instance 1 state
just dev 1 logs # View instance 1 logs
just dev all clean # Nuclear cleanup of all instances
```

Recent Improvements

  • Fixed `ENOTFOUND redpanda` errors in backend and worker.
  • Corrected Kafka broker port to 19092 across `pm2.config.cjs`, `justfile`, and `.env`.
  • Consolidated cleanup logic into reusable scripts and unified PM2 management.
  • Added infrastructure cleanup verification to ensure no state leakage.

Closes #265

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfcfd0ac24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -1,5 +1,6 @@
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { Consumer, Kafka } from 'kafkajs';
import { getTopicResolver } from '@shipsec/backend-client';

Choose a reason for hiding this comment

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

P1 Badge Add backend-client dependency for new imports

The new @shipsec/backend-client import is not declared in backend/package.json (and similarly in worker/package.json for the worker usage). In this workspace, missing declared dependencies typically cause module resolution failures during bun install/tsc/runtime (Cannot find module '@shipsec/backend-client'), so backend/worker startup will break in environments that enforce package boundaries. Add @shipsec/backend-client to each package’s dependencies (or switch to an already-declared package) to keep builds reproducible.

Useful? React with 👍 / 👎.

@betterclever betterclever force-pushed the feat/multi-instance-dev-stack branch from b22bd40 to eca0b04 Compare February 4, 2026 21:20
betterclever and others added 13 commits February 6, 2026 07:25
Add support for running multiple independent dev instances simultaneously with isolated Docker containers and PM2 processes.

Key features:
- Support instances 0-9 with clean syntax: just dev, just dev 1, just dev 2 stop
- Dynamic port offsets: instance N uses base_port + N*100
- Instance-specific Docker Compose project names (shipsec-dev-N)
- Instance-specific PM2 app naming and configuration
- Auto-generate docker-compose overrides for port mappings
- Support for 'just dev stop all' to shut everything down
- Each instance gets isolated .instances/instance-X directories with copied env files
- Temporal namespaces/task queues isolated per instance

Files added:
- scripts/dev-instance-manager.sh: Utility script for instance initialization and configuration

Files modified:
- justfile: Refactored 'dev' command to support multi-instance syntax and operations
- pm2.config.cjs: Added instance-specific app naming, ports, and env file resolution

Examples: just dev                   # Start instance 0
  just dev 1 start           # Start instance 1
  just dev 2 logs            # View logs for instance 2
  just dev 1 stop            # Stop instance 1
  just dev status all        # Check status of all instances
  just dev stop all          # Stop all instances
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c2a4b-7659-7551-9e17-b36c1669f387
Co-authored-by: Amp <amp@ampcode.com>
Comprehensive documentation for the new multi-instance dev stack feature including:
- Quick start examples
- Architecture and port allocation table
- Directory structure explanation
- Complete command reference
- Implementation details
- Best practices and troubleshooting
- Technical architecture overview
- Environment variables reference

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c2a4b-7659-7551-9e17-b36c1669f387
Co-authored-by: Amp <amp@ampcode.com>
- Dynamic port offsets (base_port + instance*100)
- Docker Compose project isolation per instance
- PM2 process isolation with instance-specific naming
- Database isolation (shipsec_instance_N)
- Temporal namespace isolation (shipsec-dev-N)
- Kafka topic isolation via KafkaTopicResolver
- Workspace dependencies for backend-client package

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c2a82-8732-76ac-8726-58b1e5ab340b
Co-authored-by: Amp <amp@ampcode.com>
- Move KafkaTopicResolver to backend/src/common and worker/src/common
- Regenerate OpenAPI client from backend spec
- Update imports in backend services to use local resolver
- Remove unnecessary exports from backend-client package

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019c2a82-8732-76ac-8726-58b1e5ab340b
Co-authored-by: Amp <amp@ampcode.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
- Configured Redpanda with separate internal and external listeners to fix host connectivity (port 19092)
- Updated dev configurations (PM2, env, justfile) to use external Kafka port 19092
- Improved 'just dev all clean' to support bulk cleanup of all instances
- Refactored instance cleanup scripts to reduce duplication
- Fixed CORS origin policy to dynamically support multiple instance ports
- Updated E2E test script for cleaner termination and parallel isolation

Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
@betterclever betterclever force-pushed the feat/multi-instance-dev-stack branch from e86a166 to 331714f Compare February 6, 2026 07:31
@betterclever betterclever merged commit 7c723b2 into main Feb 6, 2026
3 checks passed
@LuD1161 LuD1161 deleted the feat/multi-instance-dev-stack branch February 6, 2026 22:29
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