RetrievAI Deployment Guide¶
Complete guide for deploying RetrievAI v0.2.0 to your OpenStack VM using GitHub Actions.
Table of Contents¶
Prerequisites¶
On Your VM¶
- Operating System: Ubuntu 20.04+
- Software: Docker, Docker Compose, Git, NGINX
- Firewall: Allow ports 80, 443, 22.
- ChromaDB Data: Ensure your Chroma collection is present on the VM.
- Default expected path:
/srv/retrievai-data/chromadb - If different, set
CHROMA_DB_PATHin your.bashrcor update the docker-compose file.
On Your Local Machine¶
- GitHub repository access.
- OpenAI API key.
Setup Instructions¶
Step 1: Prepare VM Directories¶
# Create deployment directory
sudo mkdir -p /srv/retrievai
sudo chown $USER:$USER /srv/retrievai
# Create data directory (if not already existing)
sudo mkdir -p /srv/retrievai-data/chromadb
sudo chown -R $USER:$USER /srv/retrievai-data
Step 2: Configure NGINX¶
The deployment workflow will copy the nginx.conf to the VM and substitute ${DOMAIN_NAME} with your configured GitHub Variable.
# 1. Link the new configuration
sudo ln -sf /srv/retrievai/nginx.conf /etc/nginx/sites-available/retrievai
sudo ln -sf /etc/nginx/sites-available/retrievai /etc/nginx/sites-enabled/retrievai
# 2. Remove/Disable old configs (e.g., your existing 'streamlit' config)
sudo rm /etc/nginx/sites-enabled/default
sudo rm /etc/nginx/sites-enabled/streamlit # If this is your old config name
# 3. Test and Reload
sudo nginx -t
sudo systemctl reload nginx
Note: The new nginx.conf is configured to use the domain defined in your GitHub Variables (DOMAIN_NAME).
GitHub Configuration¶
Secrets (Settings → Secrets and variables → Actions → Secrets)¶
Required secrets for the deployment workflow:
| Secret Name | Description |
|---|---|
SSH_HOST |
IP/IPv6 of your VM (e.g., 2001:700:2:8200::2232) |
SSH_USER |
VM username (e.g., ubuntu) |
SSH_PROXY_HOST |
Jump host hostname (e.g., login.uio.no) |
SSH_PROXY_USER |
Jump host username (UiO username) |
SSH_KEY |
Private SSH key (used for target via jump host) |
OPENAI_API_KEY |
Your OpenAI API Key |
POSTGRES_PASSWORD |
Secure password for the database |
SECRET_KEY |
Secure random string for the app |
Variables (Settings → Secrets and variables → Actions → Variables)¶
| Variable Name | Value |
|---|---|
DEPLOY_PATH |
/srv/retrievai |
DOMAIN_NAME |
yourdomain.com |
Deployment¶
Automated Deployment¶
- Go to Actions tab in GitHub.
- Select Deploy to OpenStack VM.
- Click Run workflow.
- Select
productionenvironment.
The workflow will:
- SSH into the VM.
- Pull the latest code.
- Inject secrets into a .env file.
- Update NGINX config.
- Deploy with Docker Compose.
- Run database migrations.
Manual Deployment (Fallback)¶
ssh user@vm
cd /srv/retrievai
git pull
# Manually create .env file with secrets
docker compose -f docker-compose.prod.yml up -d --build
Post-Deployment¶
Verify Health¶
- Frontend:
https://yourdomain.com - API:
https://yourdomain.com/api/health - Docs:
https://yourdomain.com/docs
Data Migration¶
If you have existing data to migrate:
### Option A: Migration Scripts (Recommended if starting fresh)
```bash
# Copy migration data to VM
scp -r .retrievai/ your-user@your-vm:/srv/retrievai-data/
# Run migrations
cd /srv/retrievai
docker compose -f docker-compose.prod.yml run --rm \
-v /srv/retrievai-data/.retrievai:/app/.retrievai \
backend python /app/migration_scripts/migrate_users.py
docker compose -f docker-compose.prod.yml run --rm \
-v /srv/retrievai-data/.retrievai:/app/.retrievai \
backend python /app/migration_scripts/migrate_settings.py
docker compose -f docker-compose.prod.yml run --rm \
-v /srv/retrievai-data/.retrievai:/app/.retrievai \
backend python /app/migration_scripts/populate_documents.py
Option B: Database Dump & Restore (If you have a full local DB)¶
If you have a fully populated local database you want to clone:
-
Dump Local Database:
-
Transfer Dump to VM:
-
Restore on VM:
# SSH into VM ssh your-user@your-vm cd /srv/retrievai # Stop backend to prevent writes during restore docker compose -f docker-compose.prod.yml stop backend worker # Drop existing schema (optional, but safer for clean restore) docker compose -f docker-compose.prod.yml exec postgres psql -U retrievai -d retrievai -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" # Restore the dump # Note: We use -d retrievai to connect to the correct DB cat retrievai_dump.sql | docker compose -f docker-compose.prod.yml exec -T postgres psql -U retrievai -d retrievai # Restart services docker compose -f docker-compose.prod.yml start backend worker
Troubleshooting¶
- ChromaDB Error: Check if the volume mount path in
docker-compose.prod.ymlmatches your VM path. - Database Error: Check
POSTGRES_PASSWORDin secrets. - NGINX Error: Run
sudo nginx -tto validate config.