build cache
This commit is contained in:
+29
-6
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user