cahce 2
This commit is contained in:
+20
-8
@@ -74,23 +74,35 @@ jobs:
|
|||||||
# Enable Docker BuildKit for better caching
|
# Enable Docker BuildKit for better caching
|
||||||
export DOCKER_BUILDKIT=1
|
export DOCKER_BUILDKIT=1
|
||||||
|
|
||||||
# Try to pull previous image for cache
|
# Check if cache image exists and pull it
|
||||||
echo "Attempting to pull cache image..."
|
echo "Checking for existing cache image..."
|
||||||
docker pull "$CACHE_IMAGE" 2>/dev/null && echo "✅ Cache image pulled" || echo "ℹ️ No cache image found (first build)"
|
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..."
|
echo "Building with layer caching..."
|
||||||
docker build \
|
docker build \
|
||||||
--cache-from="$CACHE_IMAGE" \
|
$CACHE_ARGS \
|
||||||
--tag nfoguard:latest \
|
--tag nfoguard:latest \
|
||||||
--tag nfoguard:${{ github.sha }} \
|
--tag nfoguard:${{ github.sha }} \
|
||||||
--tag "$CACHE_IMAGE" \
|
--tag "$CACHE_IMAGE" \
|
||||||
.
|
.
|
||||||
|
|
||||||
echo "Docker image built and tagged successfully with caching"
|
echo "Docker image built and tagged successfully"
|
||||||
|
|
||||||
# Show layer info
|
# Show layer info for debugging
|
||||||
docker history nfoguard:latest --no-trunc | head -10
|
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)
|
- name: Login and Push to Gitea registry (local IP only)
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user