Skip to main content

Hannibal Dev Environments

All dev environments run on a single VPS: hanndev (7.7GB RAM, 4 CPU).

Environment Inventory

EnvSubdomainModeFrontendBackendPostgresRedisAI ChatNetwork~RAM
staginghannibaldev.forsyt.iofull:3000:3001hannibal-postgres:5432 / hannibalhannibal-redis:6379:8000hannibaldev_hannibal-network
prdevtesthannibal.forsyt.iolight:3002:3003hannibal-postgres / hannibal_testinghannibal-redisstaginghannibaldev_hannibal-network~140MB
pmdevbbook.forsyt.iofull:3004:3005bbook-postgres:5433 / bbookbbook-redis:6380:8001bbook_bbook-network~250MB
bhdevbhdev.forsyt.iofull:3006:3007bhdev-postgres:5434 / hannibal_bhdevbhdev-redis:6381:8002bhdev_bhdev-network~250MB
badevbadev.forsyt.iolight:3008:3009hannibal-postgres / hannibal_badevhannibal-redisstaginghannibaldev_hannibal-network~140MB

Port Map (Quick Reference)

PortService
3000staging frontend
3001staging backend
3002prdev frontend
3003prdev backend
3004pmdev frontend
3005pmdev backend
3006bhdev frontend
3007bhdev backend
3008badev frontend
3009badev backend
5432staging postgres (hannibal-postgres)
5433pmdev postgres (bbook-postgres)
5434bhdev postgres (bhdev-postgres)
6379staging redis (hannibal-redis)
6380pmdev redis (bbook-redis)
6381bhdev redis (bhdev-redis)
8000staging ai-chat
8001pmdev ai-chat
8002bhdev ai-chat

Isolation Modes

Full Isolation

Own postgres, redis, ai-chat, backend, frontend. ~250MB additional RAM.

  • Pros: No interference with other envs, can run destructive DB ops freely
  • Cons: More RAM, more containers to manage
  • Used by: staging, pmdev, bhdev

Lightweight

Only backend + frontend. Joins staging's Docker network for shared postgres/redis/ai-chat. ~140MB additional RAM.

  • Pros: Less RAM, faster to set up
  • Cons: Shares DB server (separate database though), shares Redis keyspace, shares AI chat
  • Used by: prdev, badev

Adding a New Dev Environment

# On the dev server
cd /root
git clone git@github.com:ForSyt-io/Hannibal.git {devname}
cd {devname}
git checkout feat/{devname} # or create the branch

# Run the setup script
bash docs/infra/setup-dev-env.sh --name {devname} --mode {full|light}

# Follow the printed instructions (copy .env, nginx config, certbot, etc.)

Or manually:

  1. Choose next available port pair (check Port Map above)
  2. Copy the appropriate template from docs/infra/
  3. Create .env.{devname} for backend (and ai-chat if full mode)
  4. Create nginx config from template
  5. Run certbot --nginx -d {devname}.forsyt.io
  6. docker compose -f docker-compose.{devname}.yml up -d --build
  7. Run migrations + seed

Removing a Dev Environment

# Stop and remove containers
docker compose -f docker-compose.{devname}.yml down -v

# Remove nginx config
sudo rm /etc/nginx/sites-enabled/{devname}.forsyt.io
sudo nginx -t && sudo systemctl reload nginx

# For lightweight envs, drop the database
docker exec hannibal-postgres psql -U hannibal -d hannibal -c 'DROP DATABASE hannibal_{devname};'

# Remove the repo clone
rm -rf /root/{devname}

Deploying Updates

Each dev env is a separate git clone on the server. To deploy:

cd /root/{devname}
git pull origin feat/{devname}
docker compose -f docker-compose.{devname}.yml up -d --build
docker compose -f docker-compose.{devname}.yml run --rm backend npx prisma migrate deploy

Shared Resources

  • DNS: All *.forsyt.io subdomains point to the VPS via Cloudflare wildcard
  • SSL: Certbot with nginx plugin, auto-renewal via systemd timer
  • API Keys: Betfair, Pinnacle, BetsAPI, OddsPAPI credentials are shared across all dev envs (same test accounts)
  • Web3Auth: Same client ID across all envs (configured for all subdomains)

Troubleshooting

Container won't start

docker compose -f docker-compose.{devname}.yml logs {service}

Port conflict

Check netstat -tlnp | grep {port} — another env may be using it.

Database connection refused (lightweight env)

Verify staging stack is running: docker ps | grep hannibal-postgres

Frontend shows "Authentication service error"

Check that NEXT_PUBLIC_WEB3AUTH_CLIENT_ID build arg matches the Web3Auth dashboard config. Rebuild frontend: docker compose -f docker-compose.{devname}.yml up -d --build frontend