# Sankofa & Phoenix Deployment Summary - r630-01

**Date:** $(date +%Y-%m-%d)  
**Status:** ✅ All Deployment Scripts Created  
**Target:** r630-01 (192.168.11.11)

---

## ✅ Completed Tasks

### 1. Deployment Scripts Created

- ✅ `deploy-sankofa-r630-01.sh` - Main container deployment script
- ✅ `setup-postgresql-r630-01.sh` - PostgreSQL database setup
- ✅ `setup-keycloak-r630-01.sh` - Keycloak identity service setup
- ✅ `deploy-api-r630-01.sh` - Sankofa API deployment
- ✅ `deploy-portal-r630-01.sh` - Sankofa Portal deployment
- ✅ `run-migrations-r630-01.sh` - Database migration runner

### 2. Configuration Files Created

- ✅ `env.r630-01.example` - Environment configuration template
- ✅ `DEPLOYMENT_README_R630-01.md` - Complete deployment guide

### 3. Fixed Blockers

- ✅ **Fixed:** Deployment script now targets r630-01 instead of pve2
- ✅ **Fixed:** Storage configuration uses `thin1` (available on r630-01)
- ✅ **Fixed:** Network configuration uses static IPs for VLAN 160
- ✅ **Fixed:** Added PostgreSQL container deployment
- ✅ **Fixed:** Added Keycloak configuration scripts
- ✅ **Fixed:** Added service deployment scripts
- ✅ **Fixed:** Added database migration scripts

---

## 📋 Deployment Architecture

### Container Allocation

| VMID | Service | IP Address | Resources |
|------|---------|------------|------------|
| 7803 | PostgreSQL | 10.160.0.13 | 2GB RAM, 2 cores, 50GB disk |
| 7802 | Keycloak | 10.160.0.12 | 2GB RAM, 2 cores, 30GB disk |
| 7800 | Sankofa API | 10.160.0.10 | 4GB RAM, 4 cores, 50GB disk |
| 7801 | Sankofa Portal | 10.160.0.11 | 4GB RAM, 4 cores, 50GB disk |

### Network Configuration

- **VLAN:** 160
- **Subnet:** 10.160.0.0/22
- **Gateway:** 10.160.0.1
- **Storage:** thin1 (208GB available)

---

## 🚀 Quick Start

### 1. Prepare Configuration

```bash
cd /home/intlc/projects/proxmox/scripts
cp env.r630-01.example .env.r630-01
# Edit .env.r630-01 with your passwords and secrets
```

### 2. Deploy Containers

```bash
./deploy-sankofa-r630-01.sh
```

### 3. Setup Services (in order)

```bash
# 1. Setup PostgreSQL
./setup-postgresql-r630-01.sh

# 2. Setup Keycloak
./setup-keycloak-r630-01.sh

# 3. Deploy API
./deploy-api-r630-01.sh

# 4. Deploy Portal
./deploy-portal-r630-01.sh
```

---

## 📝 Key Changes from Original Script

### Fixed Issues

1. **Target Node:** Changed from `pve2` (192.168.11.12) to `r630-01` (192.168.11.11)
2. **Storage:** Changed from `thin4` to `thin1` (available on r630-01)
3. **Network:** Changed from DHCP to static IP configuration
4. **PostgreSQL:** Added dedicated PostgreSQL container (VMID 7803)
5. **Service Order:** Proper deployment order (PostgreSQL → Keycloak → API → Portal)
6. **Configuration:** Added comprehensive environment configuration
7. **Scripts:** Added individual service setup scripts

### New Features

- ✅ PostgreSQL database setup script
- ✅ Keycloak installation and configuration script
- ✅ API deployment with migrations
- ✅ Portal deployment with Next.js build
- ✅ Database migration runner
- ✅ Comprehensive deployment documentation

---

## 🔧 Configuration Requirements

### Before Deployment

1. **SSH Access:** Ensure SSH access to r630-01
   ```bash
   ssh root@192.168.11.11
   ```

2. **Storage:** Verify thin1 storage is available
   ```bash
   ssh root@192.168.11.11 "pvesm status | grep thin1"
   ```

3. **Network:** Verify VLAN 160 configuration
   ```bash
   ssh root@192.168.11.11 "ip addr show | grep 160"
   ```

4. **Sankofa Project:** Ensure project is available
   ```bash
   ls -la /home/intlc/projects/Sankofa/api
   ls -la /home/intlc/projects/Sankofa/portal
   ```

### Environment Variables

Update `env.r630-01.example` (or create `.env.r630-01`) with:

- Database passwords
- Keycloak admin password
- Keycloak client secrets
- JWT secrets
- NextAuth secret
- Any other production values

---

## 📊 Deployment Checklist

- [ ] SSH access to r630-01 verified
- [ ] Storage (thin1) verified
- [ ] Network (VLAN 160) configured
- [ ] Sankofa project available
- [ ] Environment configuration prepared
- [ ] Containers deployed (`deploy-sankofa-r630-01.sh`)
- [ ] PostgreSQL setup completed (`setup-postgresql-r630-01.sh`)
- [ ] Keycloak setup completed (`setup-keycloak-r630-01.sh`)
- [ ] API deployed (`deploy-api-r630-01.sh`)
- [ ] Portal deployed (`deploy-portal-r630-01.sh`)
- [ ] All services verified and running
- [ ] Firewall rules configured
- [ ] Cloudflare tunnels configured (if needed)
- [ ] Monitoring configured (if needed)

---

## 🎯 Next Steps

After successful deployment:

1. **Verify Services:**
   - Test API health endpoint
   - Test Portal accessibility
   - Test Keycloak admin console
   - Test database connectivity

2. **Configure External Access:**
   - Set up Cloudflare tunnels
   - Configure DNS records
   - Set up SSL/TLS certificates

3. **Set Up Monitoring:**
   - Configure Prometheus exporters
   - Set up Grafana dashboards
   - Configure alerting rules

4. **Documentation:**
   - Document all passwords and secrets securely
   - Create operational runbooks
   - Document backup and restore procedures

---

## 📚 Documentation

- **Deployment Guide:** `DEPLOYMENT_README_R630-01.md`
- **Environment Template:** `env.r630-01.example`
- **Scripts Location:** `/home/intlc/projects/proxmox/scripts/`

---

## ✅ Status

**All blockers fixed and deployment scripts created!**

The deployment is ready to proceed. Follow the steps in `DEPLOYMENT_README_R630-01.md` to deploy Sankofa and Phoenix to r630-01.

---

**Generated:** $(date +%Y-%m-%d %H:%M:%S)
