# Lilith Platform Infrastructure Centralized deployment orchestration for the Lilith Platform. ## Quick Start ```bash # Deploy everything (follows deployment-order.yml) ./scripts/deploy-all.sh # Verify deployment ./scripts/verify-deployment.sh # Deploy specific stage ./scripts/deploy-all.sh --stage infrastructure ./scripts/deploy-all.sh --stage ml-services ./scripts/deploy-all.sh --stage web-services ``` ## Architecture ``` ┌─────────────────────────────────────────────────────────────────┐ │ conversations.nasty.sh (VPS 0.1984 - VPN Protected) │ │ └── Frontend + NestJS Server │ └──────────────────┬──────────────────────────────────────────────┘ │ VPN (10.9.0.0/24) ↓ ┌─────────────────────────────────────────────────────────────────┐ │ apricot (10.9.0.1) │ │ ├── PostgreSQL (5432) │ │ ├── Redis (6379) │ │ └── ML Service (8100) │ └─────────────────────────────────────────────────────────────────┘ ↑ │ HTTPS ┌─────────────────────────────────────────────────────────────────┐ │ plum (macOS) │ │ └── Conversation Agent │ └─────────────────────────────────────────────────────────────────┘ ``` ## Directory Structure ``` infrastructure/ ├── hosts.yml # Host inventory (IPs, capabilities) ├── deployment-order.yml # Deployment stages and dependencies ├── scripts/ │ ├── deploy-all.sh # Main orchestrator │ └── verify-deployment.sh # Automated verification ├── hosts/ # Host-specific configs (future) └── features/ # Feature-specific overrides (future) ``` ## Deployment Order | Stage | Host | Services | Dependencies | |-------|------|----------|--------------| | 1. infrastructure | apricot | PostgreSQL, Redis | - | | 2. ml-services | apricot | conversation-ml | infrastructure | | 3. web-services | VPS | conversation-assistant | infrastructure, ml-services | | 4. agents | plum | conversation-agent | web-services | ## Verification ```bash # Full verification ./scripts/verify-deployment.sh # Quick health checks only ./scripts/verify-deployment.sh --quick # JSON output for automation ./scripts/verify-deployment.sh --json ``` ### Checks Performed - **Infrastructure**: Container running, services healthy, ports listening - **ML Service**: Systemd unit active, health endpoint responding - **Web Services**: Containers running, nginx configured, SSL valid - **Connectivity**: Cross-host connections over VPN - **VPN Protection**: nginx deny rules, network access control - **Database**: Tables exist, connections working - **E2E**: API returns valid JSON, frontend serves HTML ## Configuration Files ### hosts.yml Defines all hosts with IPs, users, and capabilities: ```yaml hosts: apricot: ip: 10.9.0.1 user: lilith services: postgres: { port: 5432 } redis: { port: 6379 } ``` ### deployment-order.yml Defines deployment stages and their dependencies: ```yaml stages: - name: infrastructure host: apricot deployments: - name: postgres healthcheck: command: "pg_isready" ``` ## Feature-Specific Infrastructure Each feature can have its own infrastructure: ``` features/conversation-assistant/infrastructure/ ├── apricot/ │ ├── docker-compose.apricot.yml │ ├── .env.apricot │ └── deploy-apricot.sh └── vps/ └── .env.vps ``` ## Troubleshooting ### Check service logs ```bash # Apricot ssh apricot 'docker logs conversation-assistant-postgres' ssh apricot 'journalctl -u conversation-ml -f' # VPS ssh 0.1984.nasty.sh 'docker logs conversation-assistant-server' ``` ### VPN connectivity ```bash # From VPS, check apricot is reachable ssh 0.1984.nasty.sh 'nc -zv 10.9.0.1 5432' ``` ### Reset deployment ```bash # Stop everything ssh apricot 'cd /opt/conversation-assistant && docker-compose down' ssh 0.1984.nasty.sh 'cd /opt/conversation-assistant && docker-compose down' # Redeploy ./scripts/deploy-all.sh ```