Files
at-mintel/packages/infra/scripts/mintel-optimizer.sh
Marc Mintel 560213680c
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 6s
Monorepo Pipeline / 🧪 Test (push) Successful in 2m34s
Monorepo Pipeline / 🧹 Lint (push) Failing after 3m46s
Monorepo Pipeline / 🏗️ Build (push) Successful in 5m58s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
fix(infra): add missing Gitea cleanup commands to maintenance script
2026-03-05 23:23:09 +01:00

63 lines
2.6 KiB
Bash

#!/bin/bash
set -e
# Configuration
REGISTRY_DATA="/mnt/HC_Volume_104796416/registry-data/docker/registry/v2"
KEEP_TAGS=3
echo "🏥 Starting Aggressive Mintel Infrastructure Optimization..."
# 1. Gitea Maintenance
echo "🍵 Running Gitea Maintenance..."
GITEA_CONTAINER=$(docker ps --format "{{.Names}}" | grep gitea | head -1 || true)
if [ -n "$GITEA_CONTAINER" ]; then
# Run common Gitea cleanup tasks
docker exec -u git "$GITEA_CONTAINER" gitea admin cron run cleanup_old_repository_archives || true
docker exec -u git "$GITEA_CONTAINER" gitea admin cron run cleanup_upload_directory || true
docker exec -u git "$GITEA_CONTAINER" gitea admin cron run cleanup_packages || true
docker exec -u git "$GITEA_CONTAINER" gitea admin cron run garbage_collect_attachment || true
docker exec -u git "$GITEA_CONTAINER" gitea admin cron run garbage_collect_lfs || true
fi
# 2. Prune Registry Tags (Filesystem level)
if [ -d "$REGISTRY_DATA" ]; then
echo "🔍 Processing Registry tags..."
for repo_dir in "$REGISTRY_DATA/repositories/mintel/"*; do
[ -e "$repo_dir" ] || continue
repo_name=$(basename "$repo_dir")
# EXCLUDE base images from pruning to prevent breaking downstream builds
if [[ "$repo_name" == "runtime" || "$repo_name" == "nextjs" || "$repo_name" == "gatekeeper" ]]; then
echo " 🛡️ Skipping protected repository: mintel/$repo_name"
continue
fi
tags_dir="$repo_dir/_manifests/tags"
if [ -d "$tags_dir" ]; then
echo " 📦 Pruning mintel/$repo_name..."
# Note: keeping latest and up to KEEP_TAGS of each pattern
PATTERNS=("main-*" "testing-*" "branch-*" "v*" "rc*" "[0-9a-f]*")
for pattern in "${PATTERNS[@]}"; do
find "$tags_dir" -maxdepth 1 -name "$pattern" -print0 2>/dev/null | xargs -0 ls -dt 2>/dev/null | tail -n +$((KEEP_TAGS + 1)) | xargs rm -rf 2>/dev/null || true
done
rm -rf "$tags_dir/buildcache"* 2>/dev/null || true
fi
done
fi
# 2. Registry Garbage Collection
REGISTRY_CONTAINER=$(docker ps --format "{{.Names}}" | grep registry | head -1 || true)
if [ -n "$REGISTRY_CONTAINER" ]; then
echo "♻️ Running Registry GC..."
docker exec "$REGISTRY_CONTAINER" bin/registry garbage-collect /etc/docker/registry/config.yml --delete-untagged || true
fi
# 3. Global Docker Pruning
echo "🧹 Pruning Docker resources..."
docker system prune -af --filter "until=24h"
docker volume prune -f
echo "✅ Optimization complete!"
df -h /mnt/HC_Volume_104796416