-
-
Save hmaurer/813be1aab738a181b50c33e640006b28 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