Created
September 23, 2024 08:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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