Last active
January 19, 2026 16:59
-
-
Save abubaker417/106bb3c39a0b0c9c528a24743330bcdb to your computer and use it in GitHub Desktop.
test-deploy-local-notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Test Development Setup: | |
| # Test dev compose file | |
| docker-compose -f docker-compose.dev.yml up --build | |
| # In another terminal, test endpoints | |
| curl http://localhost:8001/health | |
| curl http://localhost:8001/docs | |
| # Check logs in real-time | |
| docker-compose -f docker-compose.dev.yml logs -f | |
| # Stop (Ctrl+C or in another terminal) | |
| docker-compose -f docker-compose.dev.yml down | |
| Test Production Setup: | |
| # Test prod compose file | |
| docker-compose -f docker-compose.prod.yml up --build | |
| # In another terminal | |
| curl http://localhost:8000/health | |
| curl http://localhost:8000/docs | |
| # Stop | |
| docker-compose -f docker-compose.prod.yml down | |
| Test Both Simultaneously: | |
| # Start dev | |
| docker-compose -f docker-compose.dev.yml up -d | |
| # Start prod | |
| docker-compose -f docker-compose.prod.yml up -d | |
| # Check both are running | |
| docker ps | |
| # Test both ports | |
| curl http://localhost:8000/health # Prod | |
| curl http://localhost:8001/health # Dev | |
| # View logs | |
| docker logs fastapi-prod | |
| docker logs fastapi-dev | |
| # Stop both | |
| docker-compose -f docker-compose.dev.yml down | |
| docker-compose -f docker-compose.prod.yml down | |
| Test Deployment Script Locally: | |
| # Make it executable | |
| chmod +x scripts/test-deploy-local.sh | |
| # Test dev deployment locally | |
| ./scripts/test-deploy-local.sh dev | |
| # Test prod deployment locally | |
| ./scripts/test-deploy-local.sh main | |
| # If both pass, you're ready to push! | |
| Test GitHub Actions Locally with 'act' | |
| Install 'act': | |
| On macOS: brew install act | |
| On Linux: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | |
| On Windows (WSL or Git Bash): curl https://raw.githubusercontent.com/nektos/act/master/install.sh | bash | |
| Run GitHub Actions locally: | |
| # List available workflows | |
| ./bin/act.exe -l | |
| # Run the workflow (dry run, won't actually deploy) | |
| ./bin/act.exe push --secret-file .secrets --dry-run | |
| # Run the workflow for dev branch | |
| ./bin/act.exe push --secret-file .secrets -j deploy --eventpath test-event.json | |
| # Run for specific branch | |
| ./bin/act.exe -W .github/workflows/deploy.yml --secret-file .secrets | |
| Cleanup Commands | |
| # Stop all containers | |
| docker stop $(docker ps -aq) | |
| # Remove all containers | |
| docker rm $(docker ps -aq) | |
| # Remove all images | |
| docker rmi $(docker images -q) | |
| # Full cleanup | |
| docker system prune -a --volumes | |
| # Remove specific containers | |
| docker-compose -f docker-compose.dev.yml down | |
| docker-compose -f docker-compose.prod.yml down | |
| Troubleshooting | |
| Port Already in Use | |
| # Find what's using the port | |
| sudo lsof -i :8000 | |
| sudo lsof -i :8001 | |
| # Kill the process | |
| sudo kill -9 <PID> | |
| Check Logs | |
| docker logs fastapi-dev | |
| docker logs fastapi-prod | |
| docker-compose logs | |
| Rebuild from Scratch | |
| docker-compose down | |
| docker system prune -a | |
| docker-compose up --build | |
| Pre-Push Checklist | |
| All files committed | |
| No .env files in git | |
| Dockerfile builds successfully | |
| Docker compose files are valid | |
| Health endpoint responds | |
| No syntax errors | |
| Tests pass locally | |
| Ready to push! | |
| Complete Local Testing Workflow: | |
| ┌─────────────────────────────────────────────┐ | |
| │ 1. Write code │ | |
| └────────────┬────────────────────────────────┘ | |
| ↓ | |
| ┌─────────────────────────────────────────────┐ | |
| │ 2. Run: ./scripts/test-before-push.sh dev │ | |
| │ - Validates all files │ | |
| │ - Builds Docker image │ | |
| │ - Starts container │ | |
| │ - Tests health endpoint │ | |
| │ - Tests other endpoints │ | |
| └────────────┬────────────────────────────────┘ | |
| ↓ | |
| All Pass? ──No──> Fix issues ──┐ | |
| │ │ | |
| Yes │ | |
| ↓ │ | |
| ┌─────────────────────────────────────────────┐ | |
| │ 3. Test manually (optional) │ | |
| │ - docker-compose up │ | |
| │ - Browse to http://localhost:8001 │ | |
| │ - Test your API endpoints │ | |
| └────────────┬────────────────────────────────┘ | |
| ↓ | |
| ┌─────────────────────────────────────────────┐ | |
| │ 4. Commit and push │ | |
| │ - git add . │ | |
| │ - git commit -m "message" │ | |
| │ - git push origin dev │ | |
| │ (Pre-push hook runs tests again) │ | |
| └────────────┬────────────────────────────────┘ | |
| ↓ | |
| ┌─────────────────────────────────────────────┐ | |
| │ 5. GitHub Actions deploys to server │ | |
| │ - Watch in GitHub Actions tab │ | |
| └─────────────────────────────────────────────┘ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment