Skip to content

Instantly share code, notes, and snippets.

@hmaurer
Forked from zimbatm/kaniko.sh
Created May 25, 2021 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmaurer/813be1aab738a181b50c33e640006b28 to your computer and use it in GitHub Desktop.
Save hmaurer/813be1aab738a181b50c33e640006b28 to your computer and use it in GitHub Desktop.
#!/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