2018-11-21 15:45:09 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
export PATH=$PATH:/kaniko/
|
|
|
|
|
2019-01-07 03:42:42 +01:00
|
|
|
if [[ -n "${PLUGIN_USERNAME}" ]]; then
|
|
|
|
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64`
|
2018-11-21 15:45:09 +01:00
|
|
|
|
2019-01-07 03:42:42 +01:00
|
|
|
REGISTRY=${PLUGIN_REGISTRY:-https://index.docker.io/v1/}
|
|
|
|
|
|
|
|
cat > /kaniko/.docker/config.json <<DOCKERJSON
|
2018-11-21 15:45:09 +01:00
|
|
|
{
|
|
|
|
"auths": {
|
2019-01-07 03:42:42 +01:00
|
|
|
"${REGISTRY}": {
|
2018-11-21 15:45:09 +01:00
|
|
|
"auth": "${DOCKER_AUTH}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DOCKERJSON
|
2019-01-07 03:42:42 +01:00
|
|
|
fi
|
2018-11-21 15:45:09 +01:00
|
|
|
|
|
|
|
DOCKERFILE=${PLUGIN_DOCKERFILE:-Dockerfile}
|
|
|
|
DESTINATION=${PLUGIN_REPO}:${PLUGIN_TAGS:-latest}
|
|
|
|
CONTEXT=${PLUGIN_CONTEXT:-$PWD}
|
|
|
|
LOG=${PLUGIN_LOG:-info}
|
2018-11-23 09:03:11 +01:00
|
|
|
BUILD_ARGS=`echo ${PLUGIN_BUILD_ARGS:-} | jq -r 'map("--build-arg " + .) | join(" ")'`
|
2018-11-21 15:45:09 +01:00
|
|
|
|
|
|
|
/kaniko/executor -v ${LOG} \
|
|
|
|
--context ${CONTEXT} \
|
|
|
|
--dockerfile ${DOCKERFILE} \
|
2018-11-23 09:03:11 +01:00
|
|
|
--destination ${DESTINATION} \
|
|
|
|
${BUILD_ARGS}
|