Created
May 25, 2021 11:32
-
-
Save zimbatm/34fa747aae09ed0c3e788129a878d841 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# A small bash wrapper to kaniko with a few assumptions built in. | |
set -euo pipefail | |
context=$1 | |
dockerfile=$2 | |
destination=$3 | |
cache=true | |
cache_repo=$(echo "$destination" | cut -d : -f 1)-cache | |
shift 3 | |
kaniko_args=( | |
--dockerfile="${dockerfile}" | |
--destination="${destination}" | |
--context=dir:///workspace/ | |
--cache="${cache}" | |
# ECR doesn't support sub-names so we need a second registry for the cache | |
--cache-repo="${cache_repo}" | |
) | |
# Build | |
docker run \ | |
-v "${context}":/workspace \ | |
-v "$HOME"/.docker/config.json:/kaniko/.docker/config.json:ro \ | |
gcr.io/kaniko-project/executor:latest \ | |
"${kaniko_args[@]}" \ | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment