Production Deployment Quick Reference
๐ Quick Startโ
# 1. Verify setup
./scripts/verify-production-setup.sh
# 2. Set up production git (if needed)
./scripts/setup-production-git.sh
# 3. Deploy
git push origin main
๐ GitHub Secrets Checklistโ
Go to: Repository โ Settings โ Secrets and variables โ Actions
-
PRODUCTION_SSH_KEY- Private SSH key -
PRODUCTION_HOST- Server IP or hostname -
PRODUCTION_USER- SSH username -
PRODUCTION_PATH- Deployment directory
๐ง Production Server Setup Commandsโ
# SSH to server
ssh your-user@your-host
# Navigate to deployment directory
cd /path/to/deployment
# Initialize git (if not done)
git init
git remote add origin git@github.com:YourUsername/YourRepo.git
git fetch origin main
git checkout -b main origin/main
# Verify git status
git status
git remote -v
git log --oneline -5
๐ GitHub SSH Key Setupโ
# On production server
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub # Copy this
# Add to GitHub:
# Settings โ SSH and GPG keys โ New SSH key
# Test connection
ssh -T git@github.com
๐ Verification Commandsโ
# Test SSH connection
ssh your-user@your-host "echo 'OK'"
# Check git repository
ssh your-user@your-host "cd /deploy/path && git status"
# Check GitHub access
ssh your-user@your-host "cd /deploy/path && git fetch origin main --dry-run"
# Check Docker
ssh your-user@your-host "docker --version && docker compose version"
ssh your-user@your-host "docker ps"
# Check deployment files
ssh your-user@your-host "ls -la /deploy/path"
๐ Monitoring Commandsโ
# Check container status
ssh your-user@your-host "cd /deploy/path && docker compose -f docker-compose.production.yml ps"
# View logs
ssh your-user@your-host "cd /deploy/path && docker compose -f docker-compose.production.yml logs --tail=50 rails"
# Follow logs in real-time
ssh your-user@your-host "cd /deploy/path && docker compose -f docker-compose.production.yml logs -f rails"
# Check health endpoint
curl https://api.bizradar.fr/up
๐ Manual Deployment Commandsโ
# SSH to production
ssh your-user@your-host
cd /deployment/path
# Pull latest code
git fetch origin main
git reset --hard origin/main
# Build and deploy
docker build -f Dockerfile.production -t odapi:latest . --no-cache
docker compose -f docker-compose.production.yml up -d
# Run migrations
docker compose -f docker-compose.production.yml run --rm rails bundle exec rails db:migrate
# Restart services
docker compose -f docker-compose.production.yml restart
# Health check
curl https://api.bizradar.fr/up
๐ Rollback Commandsโ
# SSH to production
ssh your-user@your-host
cd /deployment/path
# View recent commits
git log --oneline -10
# Reset to previous commit
git reset --hard COMMIT_HASH
# Rebuild and restart
docker build -f Dockerfile.production -t odapi:latest . --no-cache
docker compose -f docker-compose.production.yml up -d
# Verify
curl https://api.bizradar.fr/up
๐งน Cleanup Commandsโ
# Remove unused Docker images
docker image prune -af
# Remove unused containers
docker container prune -f
# Remove unused volumes
docker volume prune -f
# Remove unused networks
docker network prune -f
# Full cleanup (โ ๏ธ use with caution)
docker system prune -af --volumes
๐จ Troubleshootingโ
| Error | Quick Fix |
|---|---|
| "not a git repository" | Run ./scripts/setup-production-git.sh |
| "Permission denied (publickey)" | Set up GitHub SSH key (see above) |
| "docker: command not found" | Install Docker: curl -fsSL https://get.docker.com | sh |
| "permission denied...docker" | Add user to docker group: sudo usermod -aG docker $USER |
| Health check fails | Check logs: docker compose logs rails |
| Build fails | Check Dockerfile and .env.production |
| Migration fails | Check database connectivity |
๐ Common Workflowsโ
First Time Setupโ
1. ./scripts/verify-production-setup.sh
2. Fix any issues
3. ./scripts/setup-production-git.sh
4. Configure GitHub secrets
5. git push origin main
6. Monitor at GitHub โ Actions
Regular Deploymentโ
1. git commit -am "Your changes"
2. git push origin main
3. Monitor at GitHub โ Actions
4. Verify: curl https://api.bizradar.fr/up
Debugging Failed Deploymentโ
1. Check GitHub Actions logs
2. SSH to production server
3. cd /deployment/path
4. docker compose -f docker-compose.production.yml logs rails
5. docker compose -f docker-compose.production.yml ps
6. Check health: curl https://api.bizradar.fr/up
7. Fix issue and redeploy or rollback
Emergency Rollbackโ
1. SSH to production
2. cd /deployment/path
3. git log --oneline -5
4. git reset --hard PREVIOUS_COMMIT
5. docker build -f Dockerfile.production -t odapi:latest . --no-cache
6. docker compose -f docker-compose.production.yml up -d
๐ Quick Linksโ
- GitHub Actions: Repository โ Actions tab
- Production API: https://api.bizradar.fr
- Health Check: https://api.bizradar.fr/up
- Full Guide:
docs/SERVER_PRODUCTION_DEPLOYMENT_SETUP.md
๐ Getting Helpโ
If you encounter issues:
- Run verification script:
./scripts/verify-production-setup.sh - Check deployment logs in GitHub Actions
- SSH to server and check Docker logs
- Review
docs/SERVER_PRODUCTION_DEPLOYMENT_SETUP.md - Check server resources (disk space, memory, CPU)