The d2d application is now configured to automatically deploy updates from GitHub.
Every 15 minutes, the system:
- Checks GitHub for new commits to the
masterbranch - If updates are found, pulls the latest code
- Rebuilds the Docker container
- Restarts the application with zero downtime
- Logs all activity for review
Cron Job:
*/15 * * * * cd /opt/d2d && /opt/d2d/auto-deploy.sh >> /opt/d2d/auto-deploy.log 2>&1
Check Frequency: Every 15 minutes
Log File: /opt/d2d/auto-deploy.log
Repository: https://github.com/chrisgermon/d2d
Branch: master
GitHub Push → Wait up to 15 min → Auto-deploy checks → Pull changes →
Rebuild container → Restart app → Log results
# View live logs
tail -f /opt/d2d/auto-deploy.log
# View last 50 lines
tail -50 /opt/d2d/auto-deploy.log
# Search for errors
grep ERROR /opt/d2d/auto-deploy.log# Force deployment check now
sudo /opt/d2d/auto-deploy.sh
# Or via SSH
ssh azureuser@10.200.1.8 "cd /opt/d2d && sudo ./auto-deploy.sh"# View current cron jobs
sudo crontab -l
# Edit cron jobs
sudo crontab -e
# Remove auto-deployment
sudo crontab -l | grep -v auto-deploy.sh | sudo crontab -
# Re-enable auto-deployment
cd /opt/d2d
sudo ./setup-auto-deploy.shEdit the cron job:
sudo crontab -eOptions:
*/5 * * * * # Every 5 minutes
*/15 * * * * # Every 15 minutes (current)
0 * * * * # Every hour
0 */4 * * * # Every 4 hours
0 9,17 * * * # Twice daily (9am and 5pm)
When updates are detected, the script:
- Fetches latest changes from GitHub
- Compares local vs remote commit hashes
- Pulls changes if different
- Stops Docker containers gracefully
- Rebuilds container image with new code
- Starts containers in background
- Waits 10 seconds for startup
- Tests application is responding
- Logs all steps and status
- Edit a file on GitHub (e.g., README.md)
- Commit the change
- Wait up to 15 minutes
- Check logs:
tail -f /opt/d2d/auto-deploy.log - Verify update was deployed
# SSH to VM
ssh azureuser@10.200.1.8
# Run deployment manually
cd /opt/d2d
sudo ./auto-deploy.sh
# Watch the process# Check container is running
sudo docker-compose ps
# Test application
curl http://localhost:8000/
# Test worklist
curl -X POST http://localhost:8000/api/worklist/test \
-H 'Content-Type: application/json' \
-d '{"host":"10.17.1.21","port":5010,"ae_title":"AURVCMOD1","calling_ae":"LIVUSWL"}'[2026-01-23 22:27:42] =========================================
[2026-01-23 22:27:42] Starting auto-deployment check
[2026-01-23 22:27:42] =========================================
[2026-01-23 22:27:42] Fetching latest changes from GitHub...
[2026-01-23 22:27:43] New changes detected!
[2026-01-23 22:27:43] Local: fd3450c1234567890abcdef
[2026-01-23 22:27:43] Remote: 0a47f4e9876543210fedcba
[2026-01-23 22:27:43] Pulling changes...
[2026-01-23 22:27:44] Stopping containers...
[2026-01-23 22:27:45] Rebuilding containers...
[2026-01-23 22:27:50] Starting containers...
[2026-01-23 22:28:00] Waiting for application to start...
[2026-01-23 22:28:10] Testing application...
[2026-01-23 22:28:11] ✓ Application is running successfully
[2026-01-23 22:28:11] Container status:
[2026-01-23 22:28:11] d2d_d2d_1 Up 0.0.0.0:8000->8000/tcp
[2026-01-23 22:28:11] =========================================
[2026-01-23 22:28:11] Deployment complete!
[2026-01-23 22:28:11] =========================================
If a deployment causes issues:
# SSH to VM
ssh azureuser@10.200.1.8
# Check commit history
cd /opt/d2d
git log --oneline
# Rollback to previous version
git reset --hard <previous-commit-hash>
# Restart containers
sudo docker-compose down
sudo docker-compose build
sudo docker-compose up -dCheck if cron job exists:
sudo crontab -l | grep auto-deployIf missing, re-run setup:
cd /opt/d2d
sudo ./setup-auto-deploy.shCheck logs for errors:
grep ERROR /opt/d2d/auto-deploy.logCommon issues:
- Git authentication (should use HTTPS public repo)
- Docker build failure (check Docker logs)
- Container startup failure (check app logs)
View container logs:
cd /opt/d2d
sudo docker-compose logs --tail 100Check container status:
cd /opt/d2d
sudo docker-compose psRestart manually:
sudo docker-compose restartFull rebuild:
sudo docker-compose down
sudo docker-compose build --no-cache
sudo docker-compose up -dFor immediate deployment (not periodic), GitHub Actions can be configured to deploy on every push.
Requirement: VM needs to be accessible via SSH from GitHub (requires public IP or jump host)
Setup:
-
Add secrets to GitHub repository:
VM_HOST: Public IP or hostnameVM_USER: azureuserVM_SSH_KEY: Private SSH key content
-
GitHub Actions will deploy automatically on push to master
Status: Not currently enabled (VM is on private network)
To receive email on deployment events, modify the cron job:
*/15 * * * * cd /opt/d2d && /opt/d2d/auto-deploy.sh >> /opt/d2d/auto-deploy.log 2>&1 && mail -s "D2D Deployment" your@email.com < /opt/d2d/auto-deploy.logAdd webhook notification at the end of auto-deploy.sh:
# At end of script
curl -X POST https://hooks.slack.com/services/YOUR/WEBHOOK/URL \
-H 'Content-Type: application/json' \
-d '{"text":"D2D deployed successfully"}'- Repository is public on GitHub (read-only access)
- VM pulls changes via HTTPS (no authentication required)
- Deployment runs as root (via cron)
- Docker containers run with standard permissions
- No sensitive data in repository (uses .env for secrets)
Log Rotation: The auto-deploy script automatically keeps only the last 1000 lines of logs to prevent log file growth.
Manual cleanup:
# Clear old logs
> /opt/d2d/auto-deploy.log
# Or remove old entries
tail -1000 /opt/d2d/auto-deploy.log > /tmp/deploy-log.tmp
mv /tmp/deploy-log.tmp /opt/d2d/auto-deploy.log✅ Auto-deployment is active
- Checks every 15 minutes for GitHub updates
- Automatically rebuilds and restarts on changes
- Logs all activity to
/opt/d2d/auto-deploy.log - Zero-downtime deployments
- Easy to monitor and troubleshoot
Next deployment check: Within 15 minutes of any push to master
Document Version: 1.0 Last Updated: 2026-01-23 Status: Active ✅