From af94337ad0427ead006cd39fa2db023c78f815eb Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Tue, 9 Sep 2025 17:24:33 -0400 Subject: [PATCH] build cache --- .gitea/workflows/ci.yml | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index d4ea5a6..bd46f37 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -65,12 +65,32 @@ jobs: echo "Testing registry connectivity..." curl -s "http://$LOCAL_REGISTRY/v2/" && echo "✅ Registry accessible via HTTP" || echo "❌ Registry not accessible" - - name: Build Docker image + - name: Build Docker image with caching run: | - echo "Building Docker image..." - docker build -t nfoguard:latest . - docker tag nfoguard:latest nfoguard:${{ github.sha }} - echo "Docker image built and tagged successfully" + echo "Building Docker image with layer caching..." + LOCAL_REGISTRY="192.168.253.221:3000" + CACHE_IMAGE="$LOCAL_REGISTRY/jskala/nfoguard:buildcache" + + # Enable Docker BuildKit for better caching + export DOCKER_BUILDKIT=1 + + # Try to pull previous image for cache + echo "Attempting to pull cache image..." + docker pull "$CACHE_IMAGE" 2>/dev/null && echo "✅ Cache image pulled" || echo "ℹ️ No cache image found (first build)" + + # Build with cache-from (if available) and cache-to + echo "Building with layer caching..." + docker build \ + --cache-from="$CACHE_IMAGE" \ + --tag nfoguard:latest \ + --tag nfoguard:${{ github.sha }} \ + --tag "$CACHE_IMAGE" \ + . + + echo "Docker image built and tagged successfully with caching" + + # Show layer info + docker history nfoguard:latest --no-trunc | head -10 - name: Login and Push to Gitea registry (local IP only) run: | @@ -128,13 +148,16 @@ jobs: fi fi - # Tag for local registry + # Tag for local registry (cache image already tagged in build step) docker tag nfoguard:latest "$LOCAL_REGISTRY/jskala/nfoguard:latest" docker tag nfoguard:latest "$LOCAL_REGISTRY/jskala/nfoguard:${{ github.sha }}" echo "Pushing to LOCAL registry (gigabit speed!)..." # Push with reasonable timeout for local network + echo "=== Pushing cache image (for faster future builds) ===" + timeout 60 docker --config $DOCKER_CONFIG push "$LOCAL_REGISTRY/jskala/nfoguard:buildcache" && echo "✅ Cache image pushed" || echo "⚠️ Cache push failed" + echo "=== Pushing latest tag to LOCAL IP ===" if timeout 120 docker --config $DOCKER_CONFIG push "$LOCAL_REGISTRY/jskala/nfoguard:latest"; then echo "✅ Latest tag pushed successfully to LOCAL registry"