work correctly for non-alpine based Dockerfiles
This commit is contained in:
parent
554ce3534a
commit
017ba8156e
12
Dockerfile
12
Dockerfile
@ -1,17 +1,11 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v0.7.0 AS kaniko
|
FROM gcr.io/kaniko-project/executor:debug-v0.7.0
|
||||||
|
|
||||||
FROM alpine:3.8
|
|
||||||
|
|
||||||
# clone the official kaniko container into this one, env vars needs to be re-set
|
|
||||||
COPY --from=kaniko / /
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER /root
|
ENV USER /root
|
||||||
ENV SSL_CERT_DIR=/kaniko/ssl/certs
|
ENV SSL_CERT_DIR=/kaniko/ssl/certs
|
||||||
ENV DOCKER_CONFIG /kaniko/.docker/
|
ENV DOCKER_CONFIG /kaniko/.docker/
|
||||||
ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json
|
ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json
|
||||||
|
|
||||||
RUN apk add --update --no-cache jq
|
|
||||||
|
|
||||||
# add the wrapper which acts as a drone plugin
|
# add the wrapper which acts as a drone plugin
|
||||||
COPY plugin.sh /usr/bin/
|
COPY plugin.sh /kaniko/plugin.sh
|
||||||
ENTRYPOINT [ "/usr/bin/plugin.sh" ]
|
ENTRYPOINT [ "/kaniko/plugin.sh" ]
|
||||||
|
28
plugin.sh
28
plugin.sh
@ -1,15 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/busybox/sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
export PATH=$PATH:/kaniko/
|
export PATH=$PATH:/kaniko/
|
||||||
|
|
||||||
if [[ -n "${PLUGIN_USERNAME}" ]]; then
|
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64`
|
||||||
DOCKER_AUTH=`echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64`
|
|
||||||
|
|
||||||
REGISTRY=${PLUGIN_REGISTRY:-https://index.docker.io/v1/}
|
REGISTRY=${PLUGIN_REGISTRY:-https://index.docker.io/v1/}
|
||||||
|
|
||||||
cat > /kaniko/.docker/config.json <<DOCKERJSON
|
cat > /kaniko/.docker/config.json <<DOCKERJSON
|
||||||
{
|
{
|
||||||
"auths": {
|
"auths": {
|
||||||
"${REGISTRY}": {
|
"${REGISTRY}": {
|
||||||
@ -18,16 +17,23 @@ if [[ -n "${PLUGIN_USERNAME}" ]]; then
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DOCKERJSON
|
DOCKERJSON
|
||||||
fi
|
|
||||||
|
|
||||||
DOCKERFILE=${PLUGIN_DOCKERFILE:-Dockerfile}
|
DOCKERFILE=${PLUGIN_DOCKERFILE:-Dockerfile}
|
||||||
DESTINATION=${PLUGIN_REPO}:${PLUGIN_TAGS:-latest}
|
DESTINATION=${PLUGIN_REPO}:${PLUGIN_TAGS:-latest}
|
||||||
CONTEXT=${PLUGIN_CONTEXT:-$PWD}
|
CONTEXT=${PLUGIN_CONTEXT:-$PWD}
|
||||||
LOG=${PLUGIN_LOG:-info}
|
LOG=${PLUGIN_LOG:-info}
|
||||||
BUILD_ARGS=`echo ${PLUGIN_BUILD_ARGS:-} | jq -r 'map("--build-arg " + .) | join(" ")'`
|
case "${PLUGIN_CACHE:-}" in
|
||||||
|
true) CACHE="true" ;;
|
||||||
|
*) CACHE="false" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ -n "${PLUGIN_BUILD_ARGS:-}" ]]; then
|
||||||
|
BUILD_ARGS=$(echo "${PLUGIN_BUILD_ARGS}" | tr ',' '\n' | while read build_arg; do echo "--build-arg=${build_arg}"; done)
|
||||||
|
fi
|
||||||
|
|
||||||
/kaniko/executor -v ${LOG} \
|
/kaniko/executor -v ${LOG} \
|
||||||
--context ${CONTEXT} \
|
--context=${CONTEXT} \
|
||||||
--dockerfile ${DOCKERFILE} \
|
--dockerfile=${DOCKERFILE} \
|
||||||
--destination ${DESTINATION} \
|
--destination=${DESTINATION} \
|
||||||
${BUILD_ARGS}
|
--cache=${CACHE} \
|
||||||
|
${BUILD_ARGS:-}
|
||||||
|
Reference in New Issue
Block a user