Skip to content

Instantly share code, notes, and snippets.

@taufiqpsumarna
Created September 23, 2024 08:40
Show Gist options
  • Save taufiqpsumarna/b81ddd749d198ca4cc8d8a27012116c3 to your computer and use it in GitHub Desktop.
Save taufiqpsumarna/b81ddd749d198ca4cc8d8a27012116c3 to your computer and use it in GitHub Desktop.
Bash script build docker image using Buildkit and Docker image cache speeding up build progress
#!/bin/bash
# Define Docker image tag
TAG=${DOCKER_REGISTRY}/${REPO_NAME}:${APP_VER:latest}
echo $TAG
# Enable Docker BuildKit
export DOCKER_BUILDKIT=1
# Pull Docker image cache
echo "Pulling Docker image cache..."
docker pull "$TAG" || true
# Build Docker image
echo "Building Docker image..."
docker build -f "$DOCKERFILE_PATH" --cache-from "$TAG" -t "$TAG" .
# Push Docker image to registry
echo "Pushing Docker image to registry..."
docker push "$TAG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment