Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
520 lines
15 KiB
Markdown
520 lines
15 KiB
Markdown
# On-Demand Development Environments for Alga PSA
|
||
|
||
## Project Overview
|
||
|
||
This project aims to create an automated system for spinning up on-demand development environments for Alga PSA pull requests in Kubernetes. Each environment will be namespaced by GitHub PR number and include a complete development stack with code server, mirrord for remote development, and AI automation capabilities.
|
||
|
||
## Architecture
|
||
|
||
```
|
||
GitHub PR <20> Helm Deploy <20> K8s Namespace <20> Development Environment
|
||
<20> <20> <20>
|
||
PR-123 <20> alga-pr-123-ns <20> [Code Server + PSA + AI Tools]
|
||
```
|
||
|
||
### Core Components
|
||
|
||
1. **Kubernetes Deployment (via Helm)**
|
||
- Namespace: `alga-pr-{pr-number}`
|
||
- Based on existing `/helm` chart
|
||
- Auto-scaling and resource management
|
||
|
||
2. **Code Server Environment**
|
||
- VSCode in browser
|
||
- Pre-configured with project dependencies
|
||
- Mirrord integration for remote development
|
||
- Access to full Alga PSA codebase
|
||
|
||
3. **AI Automation Environment**
|
||
- Full AI automation stack from `/tools/ai-automation`
|
||
- Both web interface and API service
|
||
- Browser automation capabilities
|
||
- UI reflection and testing tools
|
||
|
||
4. **Enhanced Dev CLI**
|
||
- Automated environment provisioning
|
||
- Port forwarding management
|
||
- Environment lifecycle management
|
||
- Integration with existing `/cli/main.nu`
|
||
|
||
## Implementation Plan
|
||
|
||
### Phase 1: Core Infrastructure
|
||
|
||
#### 1.1 Helm Chart Extensions
|
||
- [ ] Extend existing helm chart for dev environments
|
||
- [ ] Add code-server deployment template
|
||
- [ ] Add AI automation service templates
|
||
- [ ] Configure namespace isolation and resource limits
|
||
- [ ] Add ingress/service configurations for external access
|
||
|
||
#### 1.2 Code Server Configuration
|
||
- [ ] Create Dockerfile based on provided example
|
||
- [ ] Install Node.js LTS, npm dependencies
|
||
- [ ] Pre-install Claude Code CLI
|
||
- [ ] Configure workspace with Alga PSA project
|
||
- [ ] Setup mirrord for remote development
|
||
|
||
#### 1.3 AI Automation Integration
|
||
- [ ] Package AI automation tools for K8s deployment
|
||
- [ ] Configure web interface (port 3000)
|
||
- [ ] Configure API service (port 4000)
|
||
- [ ] Setup browser session management
|
||
- [ ] Integrate with PSA instance for testing
|
||
|
||
### Phase 2: CLI Enhancement
|
||
|
||
#### 2.1 Nushell CLI Extensions
|
||
```nu
|
||
# New commands to add to cli/main.nu
|
||
|
||
# Create development environment for PR
|
||
def dev-env-create [
|
||
pr_number: int # GitHub PR number
|
||
--branch: string # Git branch (defaults to pr/pr_number)
|
||
--edition: string = "ce" # Edition: ce or ee
|
||
--ai-enabled: bool = true # Include AI automation
|
||
] {
|
||
# Implementation
|
||
}
|
||
|
||
# List active development environments
|
||
def dev-env-list [] {
|
||
# Show all running dev environments
|
||
}
|
||
|
||
# Connect to development environment
|
||
def dev-env-connect [
|
||
pr_number: int # PR number to connect to
|
||
--port-forward # Setup port forwarding
|
||
--code-server # Open code server
|
||
] {
|
||
# Implementation
|
||
}
|
||
|
||
# Destroy development environment
|
||
def dev-env-destroy [
|
||
pr_number: int # PR number to destroy
|
||
--force # Force deletion without confirmation
|
||
] {
|
||
# Implementation
|
||
}
|
||
|
||
# Get environment status and URLs
|
||
def dev-env-status [
|
||
pr_number?: int # Optional PR number, shows all if omitted
|
||
] {
|
||
# Implementation
|
||
}
|
||
```
|
||
|
||
#### 2.2 Environment Management
|
||
- [ ] Automated kubectl context management
|
||
- [ ] Port forwarding automation
|
||
|
||
### Phase 3: Advanced Features [ DELAYED ]
|
||
|
||
#### 3.1 GitHub Integration
|
||
- [ ] PR comment integration for environment URLs
|
||
- [ ] Automatic cleanup on PR merge/close
|
||
- [ ] Status badges and integration
|
||
|
||
#### 3.2 Enhanced Development Experience
|
||
- [ ] Pre-seeded database with test data
|
||
- [ ] Hot-reloading for code changes
|
||
- [ ] Integrated debugging capabilities
|
||
- [ ] Multi-user environment support
|
||
|
||
#### 3.3 AI Automation Enhancement
|
||
- [ ] PR-specific automation testing
|
||
- [ ] Automated regression testing
|
||
- [ ] UI change detection and validation
|
||
- [ ] Performance monitoring integration
|
||
|
||
## Technical Specifications
|
||
|
||
### Container Images
|
||
|
||
#### Code Server Image
|
||
```dockerfile
|
||
FROM codercom/code-server:latest
|
||
|
||
USER root
|
||
|
||
# Install Node.js LTS
|
||
RUN apt-get update && \
|
||
apt-get install -y curl ca-certificates && \
|
||
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
|
||
apt-get install -y nodejs && \
|
||
rm -rf /var/lib/apt/lists/*
|
||
|
||
# Install development tools
|
||
RUN npm install -g @anthropic-ai/claude-code && \
|
||
npm install -g mirrord
|
||
|
||
# Install kubectl and helm
|
||
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \
|
||
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
|
||
curl https://get.helm.sh/helm-v3.12.0-linux-amd64.tar.gz | tar xz && \
|
||
mv linux-amd64/helm /usr/local/bin/
|
||
|
||
USER coder
|
||
|
||
# Default workspace
|
||
WORKDIR /home/coder/alga-psa
|
||
```
|
||
|
||
#### AI Automation Image
|
||
- Based on existing `/tools/ai-automation/Dockerfile`
|
||
- Enhanced for Kubernetes deployment
|
||
- Configured for development environment integration
|
||
|
||
### Helm Values Structure
|
||
|
||
```yaml
|
||
# values-dev-env.yaml
|
||
nameOverride: "alga-dev"
|
||
namespace: "alga-pr-{{ .Values.prNumber }}"
|
||
|
||
# Code Server Configuration
|
||
codeServer:
|
||
enabled: true
|
||
image:
|
||
repository: "harbor.nineminds.com/nineminds/alga-code-server"
|
||
tag: "latest"
|
||
service:
|
||
type: "ClusterIP"
|
||
port: 8080
|
||
ingress:
|
||
enabled: true
|
||
host: "{{ .Values.prNumber }}.dev.alga.nineminds.com"
|
||
|
||
# AI Automation Configuration
|
||
aiAutomation:
|
||
enabled: true
|
||
web:
|
||
image:
|
||
repository: "harbor.nineminds.com/nineminds/alga-ai-web"
|
||
service:
|
||
port: 3000
|
||
api:
|
||
image:
|
||
repository: "harbor.nineminds.com/nineminds/alga-ai-api"
|
||
service:
|
||
port: 4000
|
||
|
||
# Resource Limits
|
||
resources:
|
||
limits:
|
||
cpu: "2"
|
||
memory: "4Gi"
|
||
requests:
|
||
cpu: "500m"
|
||
memory: "1Gi"
|
||
|
||
# Storage for persistent development
|
||
persistence:
|
||
enabled: true
|
||
size: "10Gi"
|
||
storageClass: "fast-ssd"
|
||
```
|
||
|
||
### CLI Implementation Details
|
||
|
||
#### Environment Creation Flow
|
||
1. Validate PR number and fetch branch info
|
||
2. Generate unique namespace and resource names
|
||
3. Deploy Helm chart with PR-specific values
|
||
4. Wait for deployment readiness
|
||
5. Setup port forwarding (optional)
|
||
6. Display access URLs and connection info
|
||
|
||
#### Environment Management
|
||
- Health checks via Kubernetes API
|
||
- Resource usage monitoring
|
||
- Automatic scaling based on usage
|
||
- Cleanup policies for inactive environments
|
||
|
||
### Security Considerations
|
||
|
||
#### Network Isolation
|
||
- Each PR environment in separate namespace
|
||
- Network policies for service isolation
|
||
- Ingress with authentication/authorization
|
||
- Rate limiting and resource quotas
|
||
|
||
#### Access Control
|
||
- Integration with existing authentication
|
||
- Role-based access to environments
|
||
- Audit logging for environment access
|
||
- Secure secrets management
|
||
|
||
#### Data Protection
|
||
- Isolated databases per environment
|
||
- No production data in dev environments
|
||
- Encrypted storage for persistent volumes
|
||
- Regular backup and cleanup policies
|
||
|
||
## Configuration Files
|
||
|
||
### Helm Templates Structure
|
||
```
|
||
helm/templates/dev-env/
|
||
|