From c3097bd8fe1bd99cbc96a39a17b9b013f26b9161 Mon Sep 17 00:00:00 2001 From: Leopere Date: Tue, 3 Mar 2026 11:35:07 -0500 Subject: [PATCH] Deploy: prune old images after deploy, document full rebuild/redeploy Made-with: Cursor --- docs/README.md | 4 ++++ scripts/ci-deploy-production.sh | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/README.md b/docs/README.md index cb02900..1e73c81 100644 --- a/docs/README.md +++ b/docs/README.md @@ -25,6 +25,10 @@ This directory contains comprehensive guides for Authelia deployment and configu - Monitor deployment through Woodpecker CI - Verify service health and authentication flows +4. **Full rebuild and redeploy (remove old stack/images)** + - Push to `main` (or run the production pipeline in Woodpecker). The pipeline: builds production images with `--no-cache`, pushes to registry, runs `scripts/ci-deploy-production.sh` (stack rm → wait → recreate secrets → deploy stack → health check → prune unused images). + - No manual steps on the swarm manager; everything runs in CI. + ## 🔑 Quick Reference ### Essential Commands diff --git a/scripts/ci-deploy-production.sh b/scripts/ci-deploy-production.sh index 8568f20..a88e692 100755 --- a/scripts/ci-deploy-production.sh +++ b/scripts/ci-deploy-production.sh @@ -400,6 +400,13 @@ comprehensive_health_check() { return 0 } +# Remove all unused images (old stack versions) from the node +prune_old_images() { + log "Pruning unused images (removing old versions)" + docker image prune -a -f || warning "Image prune had non-fatal issues" + success "Old image versions pruned" +} + # Main deployment function main() { log "🚀 Starting production deployment for ${CI_REPO_NAME}" @@ -434,6 +441,9 @@ main() { # Step 7-9: Rapid health checking with container diagnostics comprehensive_health_check + # Step 10: Remove old image versions from the node + prune_old_images + success "🎉 Production deployment completed successfully!" success "🏆 Deployed image: $NEW_IMAGE_HASH" }