# DBIS Core Deployment - Current Status

## Summary

Containers are created and configured, but source code deployment is blocked due to repository authentication requirements. The deployment scripts are ready and can be used once source code access is configured.

## Container Status

All 6 containers are created and running:

- ✅ **PostgreSQL Primary** (10100): Running, database configured
- ✅ **PostgreSQL Replica** (10101): Container running  
- ✅ **Redis** (10120): Running
- ✅ **API Primary** (10150): Container running, Node.js installed
- ✅ **API Secondary** (10151): Container running, Node.js installed  
- ✅ **Frontend** (10130): Container running, Node.js and Nginx installed

## What's Complete

1. ✅ All containers created with correct IPs
2. ✅ PostgreSQL database and user created
3. ✅ Node.js 18.20.8 installed via nvm in all application containers
4. ✅ Git installed in all containers
5. ✅ Systemd service files created for API containers
6. ✅ Nginx configured for frontend
7. ✅ All deployment scripts created and ready

## What's Needed

**Source Code Deployment**: The source code needs to be deployed to the containers. The repository requires authentication, so one of these options is needed:

### Option 1: Use SSH Key Authentication (Recommended)
Set up SSH keys on the containers to allow git clone from the private repository:

```bash
# On each container, set up SSH key for git access
ssh root@192.168.11.10 "pct exec 10150 -- bash -c 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N \"\" && cat ~/.ssh/id_ed25519.pub'"
# Add the public key to GitHub repository deploy keys or user account
```

### Option 2: Use Deployment Scripts with Local Source
If the source code exists on the Proxmox host at `/root/proxmox/dbis_core`, the deployment scripts can use it:

```bash
ssh root@192.168.11.10 "cd /root/proxmox/dbis_core/scripts/deployment && ./deploy-all.sh"
```

### Option 3: Copy Source Code Manually
If you have the source code accessible, copy it directly:

```bash
# From local machine
tar czf - -C /home/intlc/projects/proxmox dbis_core | ssh root@192.168.11.10 "pct exec 10150 -- bash -c 'cd /opt && tar xzf - && mv dbis_core dbis-core'"
```

## Next Steps After Source Code Deployment

Once source code is in place:

1. **Install dependencies and build**:
   ```bash
   ssh root@192.168.11.10 "pct exec 10150 -- bash -c 'source /root/.nvm/nvm.sh && cd /opt/dbis-core && npm install && npx prisma generate && npm run build'"
   ```

2. **Configure environment variables**:
   ```bash
   ssh root@192.168.11.10 "pct exec 10150 -- bash -c 'cat > /opt/dbis-core/.env <<EOF
   DATABASE_URL=postgresql://dbis:PASSWORD@192.168.11.100:5432/dbis_core
   JWT_SECRET=\$(openssl rand -hex 32)
   ALLOWED_ORIGINS=http://192.168.11.130,https://192.168.11.130
   NODE_ENV=production
   LOG_LEVEL=info
   HSM_ENABLED=false
   REDIS_URL=redis://192.168.11.120:6379
   PORT=3000
   EOF'"
   ```

3. **Start services**:
   ```bash
   ssh root@192.168.11.10 "pct exec 10150 -- systemctl restart dbis-api"
   ```

4. **Run database migrations**:
   ```bash
   ssh root@192.168.11.10 "cd /root/proxmox/dbis_core/scripts/deployment && DBIS_DB_PASSWORD=8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771 ./configure-database.sh"
   ```

## Database Credentials

- **Database**: dbis_core
- **User**: dbis
- **Password**: `8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771`
- **Host**: 192.168.11.100
- **Port**: 5432

⚠️ **Save this password securely!**

## Deployment Scripts

All deployment scripts are ready at `/root/proxmox/dbis_core/scripts/deployment/`:
- `deploy-all.sh` - Deploy all services
- `deploy-api.sh` - Deploy API containers
- `deploy-frontend.sh` - Deploy frontend
- `deploy-postgresql.sh` - Deploy PostgreSQL
- `deploy-redis.sh` - Deploy Redis
- `configure-database.sh` - Configure database

## Management Scripts

Management scripts at `/root/proxmox/dbis_core/scripts/management/`:
- `status.sh` - Check service status
- `start-services.sh` - Start all services
- `stop-services.sh` - Stop all services
- `restart-services.sh` - Restart all services

All infrastructure is ready - source code deployment is the remaining step!

