cahce 2
This commit is contained in:
+20
-8
@@ -74,23 +74,35 @@ jobs:
|
||||
# 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)"
|
||||
# Check if cache image exists and pull it
|
||||
echo "Checking for existing cache image..."
|
||||
CACHE_ARGS=""
|
||||
if curl -s "http://$LOCAL_REGISTRY/v2/jskala/nfoguard/manifests/buildcache" > /dev/null 2>&1; then
|
||||
echo "✅ Cache manifest found, pulling image..."
|
||||
if docker pull "$CACHE_IMAGE" 2>/dev/null; then
|
||||
echo "✅ Cache image pulled successfully"
|
||||
CACHE_ARGS="--cache-from=$CACHE_IMAGE"
|
||||
else
|
||||
echo "⚠️ Cache manifest exists but pull failed"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ No cache image found (first build or cache expired)"
|
||||
fi
|
||||
|
||||
# Build with cache-from (if available) and cache-to
|
||||
# Build with cache (if available)
|
||||
echo "Building with layer caching..."
|
||||
docker build \
|
||||
--cache-from="$CACHE_IMAGE" \
|
||||
$CACHE_ARGS \
|
||||
--tag nfoguard:latest \
|
||||
--tag nfoguard:${{ github.sha }} \
|
||||
--tag "$CACHE_IMAGE" \
|
||||
.
|
||||
|
||||
echo "Docker image built and tagged successfully with caching"
|
||||
echo "Docker image built and tagged successfully"
|
||||
|
||||
# Show layer info
|
||||
docker history nfoguard:latest --no-trunc | head -10
|
||||
# Show layer info for debugging
|
||||
echo "=== Image layer history ==="
|
||||
docker history nfoguard:latest --format "table {{.CreatedBy}}\t{{.Size}}" | head -5
|
||||
|
||||
- name: Login and Push to Gitea registry (local IP only)
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user