DevBox Development Environment
DevBox Development Environment
Section titled “DevBox Development Environment”TL;DR: The DevBox is a containerized development environment with all tools pre-installed, all platform services accessible, and your workspace mounted for hot-reload development.
Overview
Section titled “Overview”The DevBox container provides a complete, isolated development environment for the Banyan Platform. It eliminates “works on my machine” problems by giving every developer the exact same environment with all dependencies pre-configured.
What You’ll Learn
Section titled “What You’ll Learn”- What the DevBox is and why you should use it
- How to build and test inside the DevBox
- How to run platform services with hot-reload
- How to debug issues using DevBox tools
- DevBox vs local development trade-offs
What is the DevBox?
Section titled “What is the DevBox?”The DevBox is a Docker container that includes:
- ✅ Node.js 20 - JavaScript/TypeScript runtime
- ✅ pnpm - Package manager with workspace support
- ✅ All build tools - TypeScript, Biome, Jest pre-installed
- ✅ Development utilities - git, gh, fzf, tmux, nano, vim
- ✅ Native build tools - gcc, g++, make, python3 for native modules
- ✅ Network access to all platform services (RabbitMQ, PostgreSQL, Redis, Jaeger)
- ✅ Workspace mounted at
/workspacewith hot-reload - ✅ Persistent command history across container restarts
- ✅ Claude Code CLI for AI-assisted development
Why Use the DevBox?
Section titled “Why Use the DevBox?”Benefits
Section titled “Benefits”1. Zero Local Setup
- No need to install Node.js, pnpm, or any dependencies locally
- Works the same on macOS, Linux, and Windows
2. CI/CD Parity
- DevBox environment matches GitHub Actions exactly
- “It works in CI” = “It works on my machine”
3. Isolated Environment
- Doesn’t pollute your local system with dependencies
- Multiple platform versions can coexist
4. All Services Available
- RabbitMQ, PostgreSQL, Redis, Jaeger accessible at
localhost - No port conflicts with your local services
5. Hot Reload
- Changes to your local files immediately reflect in container
- No need to rebuild for code changes
When to Use DevBox
Section titled “When to Use DevBox”Use DevBox for:
- ✅ Building platform packages
- ✅ Running tests (unit, integration, comprehensive)
- ✅ Developing platform services (auth-service, api-gateway, etc.)
- ✅ Debugging with full observability stack
- ✅ Reproducing CI failures locally
Use Local Development for:
- ❌ Quick edits to markdown files
- ❌ Reviewing code (your IDE works better locally)
- ❌ Git operations (easier with local tools)
Getting Started
Section titled “Getting Started”Start the DevBox
Section titled “Start the DevBox”# From repository rootdocker compose up -d
# Wait for services to be ready (~30 seconds)docker compose psExpected output:
NAME STATUSflow-platform-devbox Up 30 secondsrabbitmq Up 30 seconds (healthy)postgres Up 30 seconds (healthy)redis Up 30 seconds (healthy)jaeger Up 30 secondsgrafana Up 30 secondsEnter the DevBox
Section titled “Enter the DevBox”# Open a shell in the DevBoxdocker compose exec devbox /bin/bash
# You're now inside the containernode@flow-platform-devbox:/workspace$Verify Environment
Section titled “Verify Environment”# Check versionsnode --version # v20.xpnpm --version # 8.xtsc --version # 5.x
# Check services are accessibleping -c 1 rabbitmqping -c 1 postgresping -c 1 redisCommon Development Tasks
Section titled “Common Development Tasks”Building the Platform
Section titled “Building the Platform”Build all packages:
# Inside DevBoxpnpm installpnpm run buildBuild specific package:
# Inside DevBoxcd platform/packages/corepnpm run build
# Or from root with filterpnpm --filter @banyanai/platform-core run buildWatch mode (hot-reload):
# Inside DevBoxcd platform/packages/corepnpm run dev
# Or parallel watch for all packagespnpm -r --parallel run devRunning Tests
Section titled “Running Tests”All tests:
# Inside DevBoxpnpm run testSpecific package tests:
# Inside DevBoxcd platform/packages/cqrspnpm run test
# Or from rootpnpm --filter @banyanai/platform-cqrs run testIntegration tests (require services):
# Inside DevBox - services are already running!pnpm run test:integration
# Specific integration testcd platform/packages/message-bus-clientpnpm run test -- --testPathPattern=integrationComprehensive tests:
# Inside DevBoxcd platform/packages/telemetrypnpm run test:comprehensiveWatch mode for tests:
# Inside DevBoxpnpm run test:watch
# Or specific filepnpm run test:watch CreateUserHandler.test.tsRunning Platform Services
Section titled “Running Platform Services”The platform services (auth-service, api-gateway, service-discovery) can run inside the DevBox with hot-reload.
Start all platform services:
# Inside DevBoxpnpm -r --parallel run devStart specific service:
# Inside DevBoxcd platform/services/api-gatewaypnpm run dev
# API Gateway now accessible at http://localhost:3003Check service logs:
# From host machinedocker compose logs -f devbox
# Or inside DevBox# Services log to stdoutQuality Checks
Section titled “Quality Checks”Run full quality check:
# Inside DevBox./platform/scripts/quality-check-all.shThis runs:
- TypeScript compilation
- Biome linting
- All tests
- Coverage checks (90%+ required)
Quick quality check:
# Inside DevBox./platform/scripts/quick-quality-check.shAdvanced Usage
Section titled “Advanced Usage”Multiple Terminal Sessions
Section titled “Multiple Terminal Sessions”Open multiple shells in the same DevBox:
# Terminal 1: Run tests in watch modedocker compose exec devbox /bin/bashpnpm run test:watch
# Terminal 2: Run service in dev modedocker compose exec devbox /bin/bashcd platform/services/api-gateway && pnpm run dev
# Terminal 3: Interactive debuggingdocker compose exec devbox /bin/bashUsing tmux Inside DevBox
Section titled “Using tmux Inside DevBox”The DevBox includes tmux for managing multiple panes in one shell:
# Inside DevBoxtmux
# Split horizontally: Ctrl+b then "# Split vertically: Ctrl+b then %# Switch panes: Ctrl+b then arrow keys# New window: Ctrl+b then c# Detach: Ctrl+b then d# Reattach: tmux attachDebugging with DevBox Tools
Section titled “Debugging with DevBox Tools”View RabbitMQ queues:
# Inside DevBoxcurl -u admin:admin123 http://rabbitmq:15672/api/queuesCheck PostgreSQL:
# Inside DevBoxPGPASSWORD=actor_pass123 psql -h postgres -U actor_user -d eventstore -c "\dt"Check Redis cache:
# Inside DevBoxredis-cli -h redis -a redis123 keys '*'View Jaeger traces:
# Open from host machine browseropen http://localhost:16686
# Or check if Jaeger is receiving tracescurl http://jaeger:16686/api/servicesInstalling Additional Tools
Section titled “Installing Additional Tools”# Inside DevBox (as node user)npm install -g <package-name>
# Or install system packages (requires root)docker compose exec -u root devbox apt-get updatedocker compose exec -u root devbox apt-get install -y <package-name>Accessing DevBox Files from Host
Section titled “Accessing DevBox Files from Host”All files at /workspace inside DevBox are your repository files:
# Edit on host machinecode platform/packages/core/src/index.ts
# Changes immediately available inside DevBox# DevBox watches for changes and rebuilds automaticallyDevBox Configuration
Section titled “DevBox Configuration”Environment Variables
Section titled “Environment Variables”The DevBox has access to all platform environment variables:
# Inside DevBoxecho $RABBITMQ_URL# amqp://admin:admin123@rabbitmq:5672
echo $DATABASE_URL# postgresql://actor_user:actor_pass123@postgres:5432/eventstore
echo $REDIS_URL# redis://:redis123@redis:6379Volumes
Section titled “Volumes”The DevBox mounts several volumes:
- Workspace:
.→/workspace(your code, hot-reload enabled) - Command history: Persistent bash history across restarts
- Claude config: Persistent Claude Code configuration
Services are accessible from both host and DevBox:
| Service | From Host | From DevBox |
|---|---|---|
| RabbitMQ AMQP | localhost:55671 | rabbitmq:5672 |
| RabbitMQ UI | localhost:55672 | rabbitmq:15672 |
| PostgreSQL | localhost:55432 | postgres:5432 |
| Redis | localhost:56379 | redis:6379 |
| Jaeger UI | localhost:16686 | jaeger:16686 |
| Grafana | localhost:5005 | grafana:3000 |
| API Gateway | localhost:3003 | localhost:3003 |
| Auth Service | localhost:3001 | localhost:3001 |
Troubleshooting
Section titled “Troubleshooting”DevBox Won’t Start
Section titled “DevBox Won’t Start”Problem: DevBox container fails to start
Solution 1: Check if ports are in use
# Check port conflictslsof -i :3001lsof -i :3003lsof -i :55671
# Stop conflicting processes or change ports in docker-compose.ymlSolution 2: Rebuild DevBox image
docker compose downdocker compose build devboxdocker compose up -dSolution 3: Clean volumes and restart
docker compose down -vdocker compose up -dPermission Issues
Section titled “Permission Issues”Problem: Cannot write files inside DevBox
Solution: Fix ownership
# Inside DevBoxsudo chown -R node:node /workspace
# Or from hostdocker compose exec -u root devbox chown -R node:node /workspaceTests Fail Inside DevBox but Pass Locally
Section titled “Tests Fail Inside DevBox but Pass Locally”Problem: Different environment behavior
Solution 1: Check service connectivity
# Inside DevBoxping rabbitmqping postgresping redis
# All should respondSolution 2: Check environment variables
# Inside DevBoxenv | grep -E "RABBITMQ|DATABASE|REDIS"
# Should show correct URLs with service names, not localhostSolution 3: Clear node_modules and reinstall
# Inside DevBoxrm -rf node_modules platform/*/node_modulespnpm installpnpm run buildpnpm run testSlow Build Performance
Section titled “Slow Build Performance”Problem: Builds are slower in DevBox than locally
Solution 1: Use watch mode instead of rebuilding
# Inside DevBoxpnpm -r --parallel run devSolution 2: Increase Docker resources
# Docker Desktop → Settings → Resources# CPU: 4+ cores# Memory: 8+ GB# Swap: 2+ GBSolution 3: Use build filters
# Only build what you're working onpnpm --filter @banyanai/platform-core run buildCommand History Not Persisting
Section titled “Command History Not Persisting”Problem: Bash history lost on DevBox restart
Solution: Check volume mount
# Verify volume existsdocker volume ls | grep command-history
# If missing, recreatedocker compose downdocker compose up -dServices Not Accessible
Section titled “Services Not Accessible”Problem: Cannot connect to RabbitMQ/PostgreSQL from DevBox
Solution 1: Wait for health checks
# Check service healthdocker compose ps
# All should show "healthy" or "Up"# If "starting", wait 30 seconds and check againSolution 2: Check network
# Inside DevBoxdocker network ls | grep flow-platform
# All services should be on same networkSolution 3: Restart services
docker compose restart rabbitmq postgres redisBest Practices
Section titled “Best Practices”1. Use DevBox for Clean Builds
Section titled “1. Use DevBox for Clean Builds”Before committing, verify your changes work in a clean environment:
# Inside DevBoxrm -rf node_modules platform/*/node_modulespnpm installpnpm run buildpnpm run test./platform/scripts/quality-check-all.sh2. Keep DevBox Running
Section titled “2. Keep DevBox Running”Don’t constantly stop/start DevBox:
# Start oncedocker compose up -d
# Enter/exit as neededdocker compose exec devbox /bin/bashexit
# Stop only when done for the daydocker compose down3. Use Watch Mode for Development
Section titled “3. Use Watch Mode for Development”Enable hot-reload for faster iteration:
# Terminal 1: Watch platform packagesdocker compose exec devbox /bin/bashpnpm -r --parallel run dev
# Terminal 2: Watch testsdocker compose exec devbox /bin/bashpnpm run test:watch
# Edit files on host, see changes immediately4. Match CI Environment
Section titled “4. Match CI Environment”CI runs in DevBox, so test there before pushing:
# Inside DevBoxpnpm run buildpnpm run testpnpm run lint
# If these pass, CI will pass too5. Use Persistent History
Section titled “5. Use Persistent History”Your bash history persists across restarts:
# Inside DevBoxhistory | grep pnpm
# Use Ctrl+R to search history# Use !! to repeat last command# Use !pnpm to repeat last pnpm commandComparison: DevBox vs Local vs CI
Section titled “Comparison: DevBox vs Local vs CI”| Feature | DevBox | Local | CI (GitHub Actions) |
|---|---|---|---|
| Setup time | 2 min (first time) | 15 min (install tools) | Automatic |
| Environment | Docker container | Host machine | Docker container |
| Consistency | ✅ Always same | ❌ Varies by machine | ✅ Always same |
| Service access | ✅ All services ready | ⚠️ Manual setup | ✅ All services ready |
| Hot reload | ✅ Yes | ✅ Yes | ❌ No |
| Performance | ⚠️ Slight overhead | ✅ Native speed | ⚠️ Varies |
| Debugging | ✅ Full access | ✅ Full access | ❌ Limited |
| Matches CI | ✅ Exact match | ❌ Different | ✅ Exact match |
Recommendation: Use DevBox for builds/tests, local for editing, CI for validation.
DevBox Architecture
Section titled “DevBox Architecture”graph TB Host[Your Machine] DevBox[DevBox Container] RabbitMQ[RabbitMQ Container] Postgres[PostgreSQL Container] Redis[Redis Container] Jaeger[Jaeger Container]
Host -->|Workspace mounted| DevBox Host -->|Edit files| Workspace[/workspace] Workspace -->|Hot reload| DevBox
DevBox -->|amqp://rabbitmq:5672| RabbitMQ DevBox -->|postgresql://postgres:5432| Postgres DevBox -->|redis://redis:6379| Redis DevBox -->|http://jaeger:4318| Jaeger
Host -->|Browser| Jaeger Host -->|Browser| RabbitMQ
style DevBox fill:#5f67ee,color:#fff style Workspace fill:#7d85ff,color:#fffFurther Reading
Section titled “Further Reading”- Installation Guide - Set up the platform
- Local Development - Development workflows
- Testing Services - Testing strategies
- Deployment - Production deployment
- Observability - Monitoring and debugging
Quick Reference
Section titled “Quick Reference”Start DevBox:
docker compose up -ddocker compose exec devbox /bin/bashBuild everything:
pnpm install && pnpm run buildRun all tests:
pnpm run testQuality check:
./platform/scripts/quality-check-all.shStop DevBox:
exit # Exit shelldocker compose down # Stop all servicesPro Tip: Add this alias to your ~/.bashrc or ~/.zshrc for quick DevBox access:
alias devbox='docker compose exec devbox /bin/bash'Then just run devbox to enter the container!