ERP-Unlocked Deployment Guide
This guide provides step-by-step instructions for deploying new versions of ERP-Unlocked using our PR-based deployment process with branch protection and dual deployment strategy: Coolify for Docker services via webhooks and Cloudflare Pages for the marketing site.
Table of Contents
Section titled “Table of Contents”- Pre-Deployment Checklist
- Branch Protection & PR Workflow
- Staging Deployment
- Production Deployment
- Coolify Webhook Configuration
- Rollback Procedures
- Post-Deployment Verification
- Troubleshooting
Pre-Deployment Checklist
Section titled “Pre-Deployment Checklist”1. Environment Setup
Section titled “1. Environment Setup”Ensure you have the following access and credentials:
- GitHub repository access with proper branch permissions
- Coolify admin access (staging and production instances)
- Cloudflare account access (for marketing site deployment)
- Access to monitoring systems (SigNoz, Trigger.dev dashboard)
- pnpm installed locally (for local testing)
2. Pre-Deployment Verification
Section titled “2. Pre-Deployment Verification”- All branch protection checks passing
- Code review completed and approved
- Feature flags configured appropriately
- Database migrations reviewed (if applicable)
- Security scan completed
- Performance impact assessed
3. Communication
Section titled “3. Communication”- Notify team of upcoming deployment
- Schedule deployment window if maintenance required
- Prepare rollback communication plan
Branch Protection & PR Workflow
Section titled “Branch Protection & PR Workflow”Our deployment process uses strict branch protection with automated validation:
Protected Branches
Section titled “Protected Branches”main: Production deployments (protected)staging: Staging deployments (protected)develop: Integration branch for development
Pull Request Requirements
Section titled “Pull Request Requirements”-
PR Title Format: Must follow conventional commit format
feat: add user authenticationfix(api): resolve timeout issuedocs: update deployment guide -
PR Description: Must contain meaningful description (minimum 10 characters)
-
Branch Naming: Should follow pattern
type/descriptionfeature/user-authenticationfix/pdf-processing-bughotfix/critical-security-patch -
Automated Checks: All PRs must pass:
- Branch Protection: PR validation, security scan, deployment config validation
- CI/CD Pipeline: Build validation (no push to registry)
- Code Quality: Linting, type checking, formatting
PR Workflow Process
Section titled “PR Workflow Process”-
Create Feature Branch:
Terminal window git checkout developgit pull origin developgit checkout -b feature/your-feature-name -
Make Changes and Push:
Terminal window git add .git commit -m "feat: implement your feature"git push origin feature/your-feature-name -
Create Pull Request:
- Target
developbranch for features - Target
stagingfor release candidates - Target
mainfor hotfixes (emergency only)
- Target
-
Validation Process:
- Automatic validation builds run (no registry push)
- Branch protection checks validate code quality
- Security scans check for vulnerabilities
- Manual code review by team members
Staging Deployment
Section titled “Staging Deployment”Current staging runtime truth: the canonical PDF path is
webapp -> Temporal -> temporal-worker. Staging should treatpdf-apias a legacy compatibility surface, not a required deployment success criterion.
Step 1: Merge to Staging
Section titled “Step 1: Merge to Staging”Only after PR approval and validation:
-
Create PR to staging:
Terminal window # From your feature branchgit checkout staginggit pull origin staging# Create PR: develop -> staging -
Merge Process:
- Merge approved PR to
stagingbranch - Automatic triggers: Push to
stagingtriggers deployment
- Merge approved PR to
Step 2: Monitor Build & Deployment
Section titled “Step 2: Monitor Build & Deployment”-
Watch GitHub Actions:
- Go to
https://github.com/ERP-Unlocked/ordermatic/actions - Monitor “Deploy to Staging” workflow
- Ensure components complete successfully:
build✅ (reusable build workflow)deploy-web✅ (triggers Coolify webhook)deploy-temporal-compose✅ (updatestemporal-worker/ts-temporal-workerwhen needed)deploy-pdf-worker✅ only if you are still intentionally exercising the legacy Celery pathdeploy-pdf-apiis no longer a required staging success targetdeploy-marketing✅ (deploys to Cloudflare Pages)
- Go to
-
Monitor Coolify Deployment:
- Coolify webhooks automatically trigger deployments
- Watch deployment progress in Coolify dashboard
- Verify services update with new images:
ghcr.io/ERP-Unlocked/ordermatic/webapp:staging-{sha}ghcr.io/ERP-Unlocked/ordermatic/temporal-worker:staging-{sha}(when Temporal worker changes)ghcr.io/ERP-Unlocked/ordermatic/ts-temporal-worker:staging-{sha}(when TS worker changes)ghcr.io/ERP-Unlocked/ordermatic/pdf-worker:staging-{sha}only if legacy compatibility testing is still enabled
Step 3: Verify Staging Deployment
Section titled “Step 3: Verify Staging Deployment”-
Check Coolify Services:
webapp(Port 4321, proxied through 80/443)temporal-worker(PDF extraction worker onpdf-extraction)ts-temporal-worker(non-PDF Temporal workflows)temporal-server/temporal-ui(if managed in the same staging stack)pdf-worker/redisonly if you are intentionally keeping the legacy Celery path live during drain-downpostgres(Internal, database)
-
Test Application Functionality:
- User authentication works (Clerk)
- PDF upload and processing functional
- ERP integration systems operational
- Trigger.dev background jobs running
- Database connections stable
- API endpoints responding correctly
-
Check Marketing Site:
- Cloudflare Pages deployment successful
- Marketing site accessible and functional
- Content updates deployed correctly
Step 4: Staging Approval
Section titled “Step 4: Staging Approval”- QA testing completed
- Product owner sign-off
- Technical lead approval
- Performance metrics acceptable
Production Deployment
Section titled “Production Deployment”Step 1: Release to Main Branch
Section titled “Step 1: Release to Main Branch”Only after successful staging validation:
-
Create Production PR:
Terminal window # Create PR: staging -> maingit checkout maingit pull origin main# Create PR from staging to main -
Production PR Process:
- Enhanced validation: Full security scan, deployment readiness
- Required approvals: Technical lead + product owner
- Final verification: All staging tests passed
-
Merge to Main:
- Merge approved PR to
mainbranch - Automatic triggers: Push to
maintriggers production deployment
- Merge approved PR to
Step 2: Monitor Production Deployment
Section titled “Step 2: Monitor Production Deployment”-
Watch GitHub Actions:
- Monitor “Deploy to Production” workflow
- Ensure all components deploy successfully:
build✅ (full production build)deploy-web✅ (production Coolify webhook)deploy-pdf-api✅ (production Coolify webhook)deploy-pdf-worker✅ (production Coolify webhook)deploy-marketing✅ (production Cloudflare Pages)
-
Monitor Coolify Production Deployment:
- Production webhooks trigger deployments
- Watch services restart with new images:
ghcr.io/ERP-Unlocked/ordermatic/webapp:main-{sha}ghcr.io/ERP-Unlocked/ordermatic/pdf-api:main-{sha}ghcr.io/ERP-Unlocked/ordermatic/pdf-worker:main-{sha}
Step 3: Production Verification
Section titled “Step 3: Production Verification”-
Immediate Checks (0-5 minutes):
- All services respond to health checks
- User authentication functional
- Critical API endpoints operational
- No spike in error rates
- Trigger.dev tasks running normally
-
Extended Verification (5-30 minutes):
- PDF processing pipeline functional
- Background jobs processing (ERP sync, thumbnails, etc.)
- Database performance normal
- SigNoz observability data flowing
- Cache systems working correctly
-
User Acceptance (30+ minutes):
- Monitor user feedback channels
- Watch for support tickets
- Check analytics for unusual patterns
- Verify business-critical workflows
Coolify Webhook Configuration
Section titled “Coolify Webhook Configuration”Webhook Setup
Section titled “Webhook Setup”Coolify deployments are triggered by GitHub Actions webhooks, not direct git integration:
-
Webhook URLs (configured in repository secrets):
Terminal window COOLIFY_STAGING_WEBHOOK_WEBCOOLIFY_STAGING_WEBHOOK_PDF_WORKERCOOLIFY_STAGING_WEBHOOK_PDF_API # optional legacy secret during retirement windowCOOLIFY_PRODUCTION_WEBHOOK_WEBCOOLIFY_PRODUCTION_WEBHOOK_PDF_APICOOLIFY_PRODUCTION_WEBHOOK_PDF_WORKER -
Webhook Payload:
{"branch": "main","commit": "{github.sha}","tag": "{github.sha}"} -
Service Configuration:
- Each service in Coolify has its own webhook endpoint
- Webhooks trigger image pulls from GHCR
- Images tagged with branch and commit SHA for traceability
Manual Webhook Trigger
Section titled “Manual Webhook Trigger”For emergency deployments:
# Example: Manually trigger production webapp deploymentcurl -X POST "${COOLIFY_PRODUCTION_WEBHOOK_WEB}" \ -H "Content-Type: application/json" \ -d '{ "branch": "main", "commit": "abc123...", "tag": "main-abc123" }'Rollback Procedures
Section titled “Rollback Procedures”Immediate Rollback (Critical Issues)
Section titled “Immediate Rollback (Critical Issues)”-
Identify Last Stable Deployment:
Terminal window # Check GitHub Actions for last successful deployment# Note the commit SHA from successful run -
Coolify-Based Rollback:
- Go to Coolify dashboard
- For each affected service:
- Navigate to “Deployments” tab
- Find previous stable deployment
- Click “Redeploy” with previous image
-
Emergency Manual Rollback:
Terminal window # Use previous stable image tagscurl -X POST "${COOLIFY_PRODUCTION_WEBHOOK_WEB}" \-H "Content-Type: application/json" \-d '{"branch": "main","commit": "PREVIOUS_STABLE_SHA","tag": "main-PREVIOUS_STABLE_SHA"}'
Database Rollback (If Required)
Section titled “Database Rollback (If Required)”-
Assess Database Changes:
Terminal window cd packages/dbpnpm run db:check # Check for schema drift# Review recent migration files -
Execute Database Rollback:
Terminal window cd packages/dbpnpm run db:rollback # Rollback latest migration# OR for multiple rollbacks:pnpm run db:rollback --steps=2
Marketing Site Rollback
Section titled “Marketing Site Rollback”- Cloudflare Pages Rollback:
- Navigate to Cloudflare Pages dashboard
- Select the marketing site project
- Go to “Deployments” tab
- Select previous stable deployment
- Click “Retry deployment” or “Promote to production”
Communication During Rollback
Section titled “Communication During Rollback”-
Immediate Actions:
- Notify development team via Slack/Teams
- Update internal status page
- Prepare customer communication if needed
-
Post-Rollback Process:
- Document the incident and rollback reason
- Plan hotfix or remediation strategy
- Schedule post-mortem meeting
- Update monitoring and alerting if needed
Post-Deployment Verification
Section titled “Post-Deployment Verification”Automated Monitoring
Section titled “Automated Monitoring”-
Set up alerts for:
- Application response times (SigNoz)
- Error rates and exceptions
- Database performance metrics
- Trigger.dev task execution failures
-
Monitor dashboards:
- SigNoz application performance
- Coolify infrastructure health
- Trigger.dev background job status
- User engagement analytics
Manual Verification Checklist
Section titled “Manual Verification Checklist”-
Core Functionality:
- User registration/login (Clerk)
- PDF upload and processing
- Order creation and management
- ERP integrations working
- Background job processing
-
Performance Verification:
- Page load times acceptable (<3s)
- API response times within SLA (<500ms)
- Database queries optimized
- Trigger.dev tasks completing successfully
-
Background Services:
- ERP sync tasks running (check Trigger.dev dashboard)
- PDF thumbnail generation working
- Database cleanup jobs executing
- Health checks reporting green
Troubleshooting
Section titled “Troubleshooting”Common Deployment Issues
Section titled “Common Deployment Issues”GitHub Actions Failures
Section titled “GitHub Actions Failures”Issue: Build validation fails on PR Solution:
- Check branch protection workflow logs
- Verify conventional commit format
- Ensure all required files are present
- Run local build to reproduce issue
Issue: Webhook deployment fails Solution:
- Verify webhook URLs in repository secrets
- Check Coolify webhook endpoint status
- Manually trigger webhook to test connectivity
- Review webhook payload format
Coolify Deployment Issues
Section titled “Coolify Deployment Issues”Issue: Service fails to update with new image Solution:
- Verify image exists in GHCR with correct tag
- Check Coolify logs for pull errors
- Restart Coolify deployment manually
- Verify network connectivity to GHCR
Issue: Service starts but fails health checks Solution:
- Check service logs in Coolify
- Verify environment variables are set correctly
- Test database connectivity
- Check Redis/external service availability
Branch Protection Failures
Section titled “Branch Protection Failures”Issue: PR blocked by branch protection Solution:
- Check conventional commit format:
type: description - Ensure PR description has meaningful content
- Verify security scan passes
- Fix any linting or type checking errors
Health Check Commands
Section titled “Health Check Commands”# Check service health endpointscurl -f https://your-webapp-url.com/healthcurl -f https://your-api-url.com/health
# Verify Trigger.dev task status# Visit: https://cloud.trigger.dev/projects/proj_zwlhawgpqrmanfxhquwv
# Database connectivity checkcd packages/dbpnpm run db:check
# Check recent deployments# Visit: https://github.com/ERP-Unlocked/ordermatic/actions
# Monitor application performance# Visit: your-signoz-dashboard.comEmergency Contacts
Section titled “Emergency Contacts”- Technical Lead: [Name] - [Contact]
- DevOps Engineer: [Name] - [Contact]
- Product Owner: [Name] - [Contact]
- On-call Engineer: [Name] - [Contact]
Useful Development Commands
Section titled “Useful Development Commands”# Local developmentcd apps/webapppnpm run dev # Start webapp (port 4321)
pnpm run dev # Start marketing (port 3001)
# Database operationscd packages/dbpnpm run db:migrate # Apply migrationspnpm run db:studio # Open Drizzle Studiopnpm run db:seed # Seed test data
# Background job testingcd apps/webapppnpm run trigger:dev # Start Trigger.dev developmentpnpm run trigger:test # Test monitoring setup
# Build and validationpnpm run build # Build all appspnpm run test # Run all testspnpm run lint # Lint all codeDeployment Checklist Summary
Section titled “Deployment Checklist Summary”Staging Deployment
Section titled “Staging Deployment”- Create PR with proper format and description
- Pass all branch protection checks
- Get code review approval
- Merge to
stagingbranch - Monitor automated deployment
- Verify staging functionality
- Complete QA testing
Production Deployment
Section titled “Production Deployment”- Successful staging validation
- Create staging → main PR
- Enhanced production validation
- Required production approvals
- Merge to
mainbranch - Monitor production deployment
- Complete production verification
- Monitor post-deployment metrics
Post-Deployment
Section titled “Post-Deployment”- Verify all services healthy
- Check background jobs running
- Monitor error rates and performance
- Update documentation if needed
- Communicate deployment success
Note: This deployment process ensures high reliability through automated validation, branch protection, and webhook-based deployments. Always follow the PR-based workflow and never bypass branch protection rules.