diff --git a/.agent/workflows/deploy_to_production.md b/.agent/workflows/deploy_to_production.md index 1ea9eaf..b7c38d6 100644 --- a/.agent/workflows/deploy_to_production.md +++ b/.agent/workflows/deploy_to_production.md @@ -4,13 +4,53 @@ ## Environment Context -| Feature | Local Development (Mac Mini) | Production (Alpine Linux Server) | -| :--- | :--- | :--- | -| **Hostname** | `jerxie-macbookpro` | `192.168.68.113` | -| **Root Path** | `/Users/axieyangb/Project/CortexAI` | `/home/coder/project/cortex-hub` | -| **Venv** | `source cortex-ai/bin/activate` | Internal Docker Venv (`/app/venv`) | -| **Execution** | Native Shell (Zsh) | Docker Compose | -| **Database** | `sqlite:///./data/ai-hub.db` | PostgreSQL (Docker) | +| Feature | Local Development (Mac Mini) | Production Hub (Alpine Linux) | Windows Node (Swarm) | +| :--- | :--- | :--- | :--- | +| **Hostname** | `jerxie-macbookpro` | `ai.jerxie.com` (192.168.68.113) | `192.168.68.7` | +| **Project Path** | `/Users/axieyangb/Project/CortexAI` | `/home/coder/project/cortex-hub` | `C:\CortexAgent` | +| **Execution** | Native Shell (Zsh) | Docker Compose | Scheduled Task (`CortexAgent`) | +| **Python** | `source cortex-ai/bin/activate` | Internal Docker Venv | `C:\CortexAgent\venv\Scripts\python.exe` | + +--- + +## 🚀 Hub Deployment (192.168.68.113) + +The Hub deployment is automated via a wrapper script that handles GitBucket secrets and remote rebuilding. + +### 1. Automated Command +```bash +# This script handles authentication, syncing, and remote rebuilding. +./scripts/deploy_to_prod.exp +``` + +--- + +## 🖥️ Swarm Node Deployment (Windows - 192.168.68.7) + +Windows nodes are managed natively via SSH and Scheduled Tasks. + +### 1. Synchronization +Sync the latest `agent-node` code to the production folder. We use `scp` as `rsync` is typically not available on Windows. + +```bash +# Sync source code and protos +scp -r agent-node/src/ axiey@192.168.68.7:C:/CortexAgent/src/ +``` + +### 2. Restarting the Agent +The agent runs as a Scheduled Task named `CortexAgent`. To activate changes, you MUST restart the task. **Use PowerShell** for reliable command chaining over SSH. + +```bash +ssh axiey@192.168.68.7 "powershell -Command \"Stop-ScheduledTask -TaskName CortexAgent -ErrorAction SilentlyContinue; Start-ScheduledTask -TaskName CortexAgent\"" +``` + +### 3. Verification +Verify the agent is running and connected: +1. **Process Check**: `ssh axiey@192.168.68.7 "tasklist | findstr python"` +2. **Log Check**: `ssh axiey@192.168.68.7 "powershell -Command \"Get-Content C:\CortexAgent\agent.log -Tail 20\""` +3. **UI Check**: Verify the node shows as green/online at `ai.jerxie.com/nodes`. + +--- --- @@ -72,42 +112,6 @@ --- -## Deployment Steps - -1. **Automated Secret Fetching**: The `scripts/remote_deploy.sh` script will automatically pull the production password from the GitBucket Secret Vault if the `GITBUCKET_TOKEN` is available in `/app/.env.gitbucket`. -2. **Environment Configuration**: Because the application defaults to an open/local configuration (Day 0 loopback mode) without OIDC, it is critical that the production `.env` file is populated with the correct authenticating variables if using SSO: - - `OIDC_CLIENT_ID=cortex-server` - - `OIDC_CLIENT_SECRET=change-me-at-runtime` - - `OIDC_SERVER_URL=http://localhost:8080` - - `OIDC_REDIRECT_URI=http://localhost:8002/api/v1/users/login/callback` - *(Ensure these are mapped in your production deployment toolchain or manually placed on the server under `/home/coder/project/cortex-hub/.env`)* -3. **Auto-Generate API Docs**: Before deploying, if any backend API changes have been made, regenerate the documentation: - ```bash - cd /app/ai-hub && python3 /app/.agent/utils/generate_api_docs.py - ``` -4. **Sync**: Sync local codebase to `/tmp/cortex-hub/` on the server. -5. **Proto & Version Management**: - - If `ai-hub/app/protos/agent.proto` has changed, regenerate stubs: - ```bash - cd /app/ai-hub/app/protos && python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. agent.proto - cd /app/agent-node && python3 -m grpc_tools.protoc -Iprotos --python_out=. --grpc_python_out=. protos/agent.proto - ``` - - **Triggering Client Updates**: To force all active agents (like the Mac Mini) to pull new code or skills, bump the version in `/app/agent-node/VERSION`. - - **Auto-Update**: Once deployed, agents check for version mismatches every 5 minutes and will automatically re-bootstrap themselves if a newer version is detected on the Hub. -6. **Migrate & Rebuild**: Overwrite production files and run `bash scripts/local_rebuild.sh` on the server. Use `--fast` to skip container rebuilds for pure code/Python updates. -7. **Post-Deployment Health Check**: Perform a backend connectivity check (Python Trick). Only use `/frontend_tester` as a last resort if UI behavior is suspect. - -### Automated Command -```bash -# This script handles authentication, syncing, and remote rebuilding. -bash /app/scripts/remote_deploy.sh - -# If you want to deploy quickly without rebuilding the standalone agent binaries: -bash /app/scripts/remote_deploy.sh --skip-binaries - -# ULTRA-FAST: Skip container rebuilds AND binary builds (best for code-only tweaks): -bash /app/scripts/remote_deploy.sh --fast -``` ---