Development Workflow Guide¶
This guide explains the streamlined development workflow implemented to solve Issue #210: Docker Development Workflow Problem.
Problem Solved¶
Previously, developers faced these issues: - Code changes weren't reflected in running containers - Docker Compose defaulted to remote GHCR images instead of local builds - Manual intervention required to force local image usage - Inconsistent environment variables between development and production - Multiple manual steps: build โ recreate โ restart
Solution Overview¶
The new development workflow provides: - Development-first Docker Compose (docker-compose.dev.yml) - Smart Make targets for automated workflow - Development-specific environment (.env.dev) - Automatic local image building and usage - Validation commands to ensure local changes are running
Quick Start¶
Option 1: Dev Container + Host Docker (Recommended)¶
For consistent development environments across machines:
-
Open in Dev Container:
-
Use Dev Container for:
- Code editing
- Python development
- VS Code extensions
-
Development tools (make, git, etc.)
-
Use Host Terminal for:
- Docker commands
- Container management
- Service orchestration
Option 2: Host Development¶
For direct development on host machine:
1. Initialize Development Environment¶
This creates.env.dev from env.dev.example with development-specific settings. 2. Build Development Images¶
Builds local images withdev tags for backend, frontend, and test containers. 3. Start Development Environment¶
Starts all services using local builds with development environment variables.4. Validate Everything is Working¶
Checks that development images exist, containers are running, and services are healthy.Development Workflow Commands¶
Core Commands¶
| Command | Description |
|---|---|
make dev-init | Initialize development environment (.env.dev) |
make dev-build | Build local development images |
make dev-up | Start development environment with local builds |
make dev-restart | Rebuild and restart with latest changes |
make dev-down | Stop development environment |
make dev-logs | View development environment logs |
make dev-status | Show development environment status |
make dev-validate | Validate development environment health |
Typical Development Cycle¶
- Make code changes in your editor
- Restart with changes:
make dev-restart - Check status:
make dev-status - View logs if needed:
make dev-logs - Validate health:
make dev-validate
Architecture¶
Development Docker Compose (docker-compose.dev.yml)¶
Key features: - Local builds by default (no GHCR images) - Development environment variables (TESTING=true, SKIP_AUTH=true, DEVELOPMENT_MODE=true) - Source code mounting for hot reloading (./backend:/app:ro) - Writable logs directory (./logs:/app/logs) - Consistent image tags (rag-modulo/backend:dev, rag-modulo/frontend:dev)
Development Environment (.env.dev)¶
Contains development-specific settings: - Development mode flags - Development JWT secret - Development WatsonX credentials - Development database configuration - Development-specific chunking settings
Smart Make Targets¶
The Makefile includes comprehensive development targets: - Automated building with BuildKit support - Environment validation - Health checking - Status reporting - Log viewing
Service URLs¶
When running, services are available at: - Backend: http://localhost:8000 - Frontend: http://localhost:3000 - MLflow: http://localhost:5001
Environment Variables¶
Development Mode Flags¶
Development Credentials¶
JWT_SECRET_KEY=dev-jwt-secret-key-for-local-development-only
WATSONX_APIKEY=your-dev-watsonx-apikey
WATSONX_URL=https://us-south.ml.cloud.ibm.com
Troubleshooting¶
Common Issues¶
1. Containers Not Starting¶
# Check logs
make dev-logs
# Validate environment
make dev-validate
# Restart everything
make dev-down && make dev-up
2. Images Not Found¶
3. Environment Variables Not Loading¶
# Reinitialize environment
make dev-init
# Check .env.dev file exists and has correct values
ls -la .env*
4. Backend Health Check Failing¶
# Check backend logs specifically
docker compose -f docker-compose.dev.yml logs backend
# Restart backend only
docker compose -f docker-compose.dev.yml restart backend
Validation Checklist¶
Run make dev-validate to check: - โ
Development images exist - โ
Containers are running - โ
Backend is healthy (http://localhost:8000/health) - โ
Frontend is healthy (http://localhost:3000)
Comparison: Old vs New Workflow¶
Old Workflow (Problematic)¶
# Multiple manual steps
make build-backend
docker compose down
docker compose up -d
# Often used remote images instead of local builds
# Environment variables had to be set manually
# No validation that local changes were running
New Workflow (Streamlined)¶
# Single command for full cycle
make dev-restart
# Or step by step
make dev-build # Build local images
make dev-up # Start with local builds
make dev-validate # Confirm everything works
Benefits¶
Developer Experience¶
- Faster iteration: Changes visible immediately
- Fewer manual steps: Automated workflow
- Clear feedback: Know when local changes are active
- Consistent environment: Same dev setup for all developers
Reduced Errors¶
- No more old code: Always running latest changes
- Consistent env vars: Development settings always applied
- Clear state: Know which image/configuration is running
Team Productivity¶
- Onboarding: New developers can start quickly
- Debugging: Easier to reproduce and fix issues
- Testing: Faster validation of changes
Integration with Existing Workflow¶
The development workflow integrates seamlessly with existing commands:
- Production builds:
make build-backend(unchanged) - Production deployment:
make run-ghcr(unchanged) - Testing: All existing test commands work with development environment
- CI/CD: Production pipeline unchanged
Security Considerations¶
- Development settings don't leak to production
- Clear separation between dev and prod configurations
- Development JWT secrets are different from production
- Development credentials are isolated
Performance¶
- Development builds are fast (uses Docker layer caching)
- Multi-stage builds optimized for development
- Hot reloading for frontend changes
- Source code mounting for backend changes
Maintenance¶
- Keep development workflow simple
- Regular validation that dev workflow works
- Clear documentation and examples
- Automated health checks
Enhanced Developer Experience (Issue #170 Integration)¶
Complete Development Setup¶
One-command setup for new feature development that: - โ Initializes development environment - โ Builds all local images - โ Starts development environment - โ Validates everything is working - โ Provides clear next steps
Development Environment Management¶
# Reset to clean state (useful when things get messy)
make dev-reset
# Complete cleanup (destructive - removes all data)
make clean-all
Test-Driven Development¶
Watches backend/tests/ directory and runs atomic tests automatically on file changes.
VS Code Dev Container¶
The project includes a complete VS Code dev container configuration (.devcontainer/devcontainer.json) with:
- โ Pre-configured extensions: Python, Ruff, Docker, GitHub Copilot, Jupyter
- โ Automatic port forwarding: Backend (8000), Frontend (3000), MLflow (5001)
- โ Development environment: All tools pre-installed
- โ Debugging support: Ready-to-use debug configurations
- โ File watching: Optimized for development workflow
To use: 1. Open project in VS Code 2. Click "Reopen in Container" when prompted 3. Wait for container to build and start 4. Start coding!
GitHub Codespaces Support¶
The project fully supports GitHub Codespaces for cloud-based development:
- โ Consistent environment: Same Dev Container configuration as local
- โ Zero local setup: Just a web browser required
- โ Cross-platform: Works on any device (Windows, Mac, Linux, Chromebook)
- โ Team collaboration: Share Codespaces for pair programming
- โ Hot reloading: Same development experience as local
To use Codespaces: 1. Go to GitHub repository โ "Code" โ "Codespaces" 2. Click "Create codespace on main" (or your branch) 3. Wait for environment to load (2-3 minutes) 4. Start coding in browser-based VS Code!
See GitHub Codespaces Guide for complete details.
Automated PR Validation¶
The project includes automated GitHub Actions workflows for PR validation:
PR Codespace Creation¶
- โ Automatic Codespace: Creates Codespace for each PR
- โ PR Comments: Automatically comments with Codespace URL
- โ Environment Validation: Ensures Dev Container works
- โ Quick Testing: Enables immediate testing of PR changes
Codespace Testing Workflow¶
- โ Automated Testing: Runs tests in Codespace environment
- โ Hot Reloading Validation: Tests file change detection
- โ CLI Testing: Validates all CLI commands work
- โ Service Validation: Ensures all services start correctly
Environment Validation¶
- โ Dev Container Validation: Ensures configuration works
- โ Tool Availability: Verifies all development tools installed
- โ Extension Validation: Confirms VS Code extensions work
- โ
Workflow Commands: Tests all
maketargets
Workflow Files: - .github/workflows/pr-codespace.yml - PR Codespace creation - .github/workflows/codespace-testing.yml - Automated testing - .github/workflows/codespace-validation.yml - Environment validation
Related Issues¶
This implementation addresses: - Issue #210: Docker Development Workflow Problem - Issue #170: Developer Experience Improvements (integrated above) - Issue #208: Mock user initialization (benefits from streamlined workflow) - Issue #207: Search quality issues (faster iteration helps debugging)
Phase 2: Enhanced Development Experience¶
Auto-rebuild on Changes (File Watchers)¶
Automatically rebuilds and restarts the development environment when files change in backend/ or webui/ directories.
Requirements: - macOS: brew install fswatch - Linux: sudo apt-get install inotify-tools
Features: - โ
Watches for file changes in backend and frontend - โ
Automatically triggers make dev-restart on changes - โ
Cross-platform support (macOS/Linux) - โ
Graceful error handling if watcher not available
Phase 3: Advanced Features¶
Debug Mode¶
Starts the development environment with enhanced debugging capabilities.
Features: - โ
Additional logging enabled (DEBUG=true, LOG_LEVEL=DEBUG) - โ
Debug shell access: docker compose -f docker-compose.dev.yml exec backend bash - โ
Enhanced error reporting - โ
Debug logs available with make dev-logs
Test Mode¶
Starts the development environment with isolated test data and test-specific configurations.
Features: - โ
Isolated test environment (.env.test) - โ
Test-specific database configuration - โ
Mock data and test fixtures - โ
Test mode flags enabled (TESTING=true, TEST_DATA_MODE=true)
Profiling Mode¶
Starts the development environment with performance profiling and metrics collection.
Features: - โ
Performance monitoring enabled (PROFILING=true) - โ
Metrics collection (METRICS_ENABLED=true) - โ
Performance data available at http://localhost:8000/metrics - โ
Profiling data collected in ./logs/profiling/
Complete Feature Matrix¶
| Feature | Phase | Status | Command |
|---|---|---|---|
| Local builds by default | 1 | โ | make dev-build |
| Development environment variables | 1 | โ | make dev-init |
| Smart Make targets | 1 | โ | make dev-up, make dev-restart |
| Health validation | 2 | โ | make dev-validate |
| Status reporting | 2 | โ | make dev-status |
| Environment validation | 2 | โ | make dev-validate |
| Auto-rebuild on changes | 2 | โ | make dev-watch |
| Debug mode | 3 | โ | make dev-debug |
| Test mode | 3 | โ | make dev-test |
| Performance profiling | 3 | โ | make dev-profile |
| Complete dev setup | 170 | โ | make dev-setup |
| Environment reset | 170 | โ | make dev-reset |
| Complete cleanup | 170 | โ | make clean-all |
| Test watching | 170 | โ | make test-watch |
| VS Code dev container | 170 | โ | .devcontainer/devcontainer.json |
This development workflow was implemented to solve Issue #210 and significantly improve the developer experience for RAG Modulo.