Preview Environment Quick Reference
#
A quick reference guide for common tasks and commands.
Quick Start
#
# 1. Create PR targeting 'main' branch
git push origin your-feature-branch
# 2. Add 'preview' label to PR on GitHub
# 3. Wait ~40 minutes for environment to be ready
# 4. Access via URL in PR comments
Common URLs
#
| Service |
URL Pattern |
| Main App |
https://app--dev--{workspace}--{owner}.coder.internal.gotofu.com/ |
| Swagger Editor |
https://swagger-editor--dev--{workspace}--{owner}.coder.internal.gotofu.com/ |
| API Docs |
https://swagger-internal--dev--{workspace}--{owner}.coder.internal.gotofu.com/ |
| Coder Dashboard |
https://coder.internal.gotofu.com/workspaces |
Replace:
{workspace} = coder-preview-{PR-number}
{owner} = Coder username
Timeline
#
| Action |
Duration |
What Happens |
| Initial Creation |
~40 min |
Full environment setup |
| Code Update |
~10 min |
Rebuild with latest changes |
| Restart |
~2-3 min |
Restart stopped workspace |
| Cleanup |
~2 min |
Delete when PR closes |
Common Commands
#
Via Coder Web Terminal
#
# Navigate to project
cd ~/bonsai
# Check service status
docker compose -f docker-compose.preview.yml ps
# View logs (all services)
docker compose -f docker-compose.preview.yml logs -f
# View logs (specific service)
docker compose -f docker-compose.preview.yml logs -f bonsapi
# Restart all services
docker compose -f docker-compose.preview.yml restart
# Restart specific service
docker compose -f docker-compose.preview.yml restart webapp
# Check resource usage
docker stats
# Check disk space
df -h
Database Commands
#
# Access database shell
docker exec -it database psql -U postgres -d bonsai
# Common queries
\dt # List tables
\d table_name # Describe table
SELECT * FROM users LIMIT 5; # Query data
# Backup database
docker exec database pg_dump -U postgres bonsai > backup.sql
# Restore database
cat backup.sql | docker exec -i database psql -U postgres bonsai
RabbitMQ Management
#
# Check queues
docker exec bonsai-rabbitmq rabbitmqctl list_queues
# Purge specific queue
docker exec bonsai-rabbitmq rabbitmqctl purge_queue <queue-name>
# Or use web UI
# Access via Coder workspace apps
Redis Commands
#
# Access Redis CLI
docker exec -it bonsai-redis redis-cli
# Common commands
KEYS * # List all keys
GET key_name # Get value
FLUSHALL # Clear all data (careful!)
Troubleshooting Quick Fixes
#
Environment not accessible
#
# 1. Check workspace status
Visit: https://coder.internal.gotofu.com/workspaces
# 2. If stopped, start it
Click "Start" → Wait 2-3 minutes
# 3. If unhealthy, check logs
Workspace page → Builds → View logs
Service not responding
#
# 1. Check which service is down
docker compose -f docker-compose.preview.yml ps
# 2. Restart the service
docker compose -f docker-compose.preview.yml restart <service-name>
# 3. Check logs for errors
docker compose -f docker-compose.preview.yml logs <service-name> --tail=100
502 Bad Gateway
#
# 1. Check backend service
docker compose -f docker-compose.preview.yml ps bonsapi
# 2. Restart if needed
docker compose -f docker-compose.preview.yml restart bonsapi
# 3. Restart nginx proxy
docker compose -f docker-compose.preview.yml restart nginx-proxy
Changes not reflecting
#
# 1. Verify PR has 'preview' label
# 2. Check GitHub Actions for rebuild
# 3. Manually restart if needed
Coder Dashboard → Workspace → Restart
Out of disk space
#
# Clean Docker resources
docker system prune -a
docker volume prune
# Clean Rust build cache
cd ~/bonsai && cargo clean
# Clean Node modules (requires reinstall)
rm -rf node_modules apps/webapp/node_modules
Integration Setup
#
Xero
#
# 1. Get preview URL from PR
# 2. Contact developer with OAuth admin access
# 3. Provide: Preview URL + PR number
# 4. Developer adds redirect URI in Xero Developer Portal
# 5. Connect via Settings → Integrations → Xero → Connect
QuickBooks Online
#
# 1. Get preview URL from PR
# 2. Contact developer with QBO admin access
# 3. Provide: Preview URL + PR number
# 4. Developer adds redirect URI in QuickBooks Developer Portal
# 5. Connect via Settings → Integrations → QuickBooks → Connect
SharePoint
#
# 1. Get preview URL from PR
# 2. Contact developer with Azure AD admin access
# 3. Provide: Preview URL + SharePoint site + PR number
# 4. Developer adds redirect URI in Azure Portal
# 5. Wait ~5 minutes for propagation
# 6. Connect via Settings → Integrations → SharePoint → Connect
Status Indicators
#
Workspace Status (Coder Dashboard)
#
| Status |
Meaning |
Action |
| 🟢 Running + Healthy |
All good |
Use normally |
| 🟡 Starting |
Booting up |
Wait 2-3 minutes |
| 🟡 Building |
Setting up |
Wait 10-40 minutes |
| 🔴 Unhealthy |
Service issues |
Check logs, restart |
| 🔴 Failed |
Build failed |
Check build logs, fix code |
| ⚫ Stopped |
Auto-stopped or manual |
Click “Start” |
GitHub Actions Status
#
| Status |
Meaning |
| ✅ Success |
Environment ready or updated |
| 🟡 In Progress |
Creating or updating |
| ❌ Failed |
Build or deployment error |
| ⚪ Queued |
Waiting to start |
| State |
Cost/Hour |
Monthly (8h/day, 5d/week) |
| Running |
~$0.15 |
~$24 |
| Stopped |
~$0.02 |
~$7 (storage only) |
| Deleted |
$0.00 |
$0 |
Tips:
- ✅ Auto-stop after 30h inactivity (saves costs)
- ✅ Close PR when done (triggers cleanup)
- ✅ Share environments instead of creating duplicates
| Issue Type |
Contact |
| Infrastructure/Coder |
#devops on Slack |
| Application bugs |
#engineering on Slack |
| Integration OAuth setup |
Developer with admin access |
| Test account access |
Team lead or IT |
| Urgent production issues |
#incidents on Slack |
Useful Links
#
Checklist for Testing
#
Before Creating Preview
#
After Preview Created
#
Testing Changes
#
Before Closing PR
#
Resource Specifications
#
| Resource |
Specification |
| Instance Type |
AWS EC2 t3.2xlarge |
| CPU |
8 vCPUs |
| Memory |
32 GB RAM |
| Storage |
500 GB SSD (gp3) |
| Region |
ap-northeast-1 (Tokyo) |
| Docker Mode |
Rootless (enhanced security) |
Environment Variables
#
Access in workspace terminal:
# View all environment variables
env | grep -E "(DATABASE|REDIS|RABBITMQ|AWS|CLERK)"
# Common variables
echo $DATABASE_URL
echo $REDIS_URL
echo $RABBITMQ_URL
echo $NEXT_PUBLIC_BONSAPI_HOST
Data Persistence
#
| Data Type |
Persists on Update? |
Persists on Stop? |
Persists on Delete? |
| Database data |
✅ Yes |
✅ Yes |
❌ No |
| File uploads |
✅ Yes |
✅ Yes |
❌ No |
| Redis cache |
✅ Yes |
✅ Yes |
❌ No |
| RabbitMQ queues |
✅ Yes |
✅ Yes |
❌ No |
| Code changes |
✅ Yes (auto-pull) |
✅ Yes |
❌ No |
| In-memory data |
❌ No |
❌ No |
❌ No |
| Active sessions |
❌ No |
❌ No |
❌ No |
Need More Help?
#
Pro Tip: Bookmark this page for quick reference! 🔖