4.2 KiB
4.2 KiB
Deploying VRBattles API with Dokploy
Prerequisites
- Dokploy installed on your server
- Git repository (Gitea, GitHub, GitLab, etc.)
Quick Start
Step 1: Push to Git
git add .
git commit -m "Add production deployment configs"
git push origin main
Step 2: Create Project in Dokploy
- Open Dokploy dashboard
- Click "Create Project" → Give it a name (e.g., "VRBattles")
- Click "Add Service" → Select "Compose"
Step 3: Configure the Compose Service
- Source: Select your Git provider and repository
- Branch:
main(or your default branch) - Compose Path:
docker-compose.prod.yml
Step 4: Set Environment Variables
In Dokploy's Environment tab, add these required variables:
| Variable | Example | Description |
|---|---|---|
JWT_SECRET |
$(openssl rand -base64 32) |
Generate a secure random string |
POSTGRES_PASSWORD |
your_secure_db_password |
Database password |
FRONTEND_URL |
https://vrbattles.com |
Your frontend URL |
BASE_URL |
https://api.vrbattles.com |
API base URL |
Optional variables (for S3 storage):
S3_BUCKETS3_REGIONAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
Step 5: Configure Domain (Optional)
- Go to Domains tab in Dokploy
- Add your domain:
api.yourdomain.com - Dokploy will auto-configure SSL via Let's Encrypt
Step 6: Deploy!
Click "Deploy" and watch the logs.
Architecture
┌─────────────────────────────────────────────────┐
│ Dokploy │
│ ┌─────────────────────────────────────────┐ │
│ │ docker-compose.prod.yml │ │
│ │ ┌─────────────┐ ┌──────────────┐ │ │
│ │ │ api:3000 │────│ db:5432 │ │ │
│ │ │ (Rust API) │ │ (PostgreSQL) │ │ │
│ │ └─────────────┘ └──────────────┘ │ │
│ │ │ │ │ │
│ │ ▼ ▼ │ │
│ │ uploads_data postgres_data │ │
│ │ (volume) (volume) │ │
│ └─────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Traefik (reverse proxy) │
│ SSL termination │
└─────────────────────────────────────────────────┘
│
▼
https://api.yourdomain.com
Useful Commands
View Logs
In Dokploy UI → Logs tab, or SSH to server:
docker compose -f docker-compose.prod.yml logs -f api
Access Database
docker compose -f docker-compose.prod.yml exec db psql -U postgres -d vrbattles
Manual Deploy
docker compose -f docker-compose.prod.yml up -d --build
Backup Database
docker compose -f docker-compose.prod.yml exec db pg_dump -U postgres vrbattles > backup.sql
Troubleshooting
API won't start
- Check logs in Dokploy
- Verify
DATABASE_URLis correct - Ensure
JWT_SECRETis set
Database connection failed
- Check if db service is healthy
- Verify
POSTGRES_PASSWORDmatches in both services
Uploads not working
- Check
uploads_datavolume is mounted - Verify
BASE_URLis set correctly - For S3: check AWS credentials
Migrating Data
If you have existing data to import:
# Copy SQL dump to server
scp backup.sql user@server:/tmp/
# Import into running container
docker compose -f docker-compose.prod.yml exec -T db psql -U postgres -d vrbattles < /tmp/backup.sql