1
0
Fork 0

Add entrypoint.sh

This commit is contained in:
Tommy 2024-11-04 21:18:09 +00:00
parent 058c26ed51
commit fb2f8f6589
No known key found for this signature in database
GPG key ID: CF3AFE4D5B62BB9A

83
entrypoint.sh Normal file
View file

@ -0,0 +1,83 @@
#!/bin/sh
#SPDX-FileCopyrightText: 2024 Håvard Moen <post@haavard.name>
#
#SPDX-License-Identifier: GPL-3.0-only
set -e
set -- /kaniko/executor
if [ -n "${INPUT_CREDENTIALS}" ]
then
echo '{"auths": {' > /kaniko/.docker/config.json
for CREDENTIAL in ${INPUT_CREDENTIALS}
do
echo "${CREDENTIAL}" | ( IFS='=' read -r server creds
auth="$(echo -n "${creds}" | base64 -w0)"
echo "\"${server}\": {\"auth\": \"${auth}\"}," >> /kaniko/.docker/config.json
)
done
# remove last comma
sed -i '$s/,$//' /kaniko/.docker/config.json
echo '}}' >> /kaniko/.docker/config.json
fi
if [ -n "${INPUT_DOCKER_FILE}" ]
then
set -- "$@" --dockerfile "${INPUT_DOCKER_FILE}"
fi
if [ -n "${INPUT_CONTEXT}" ]
then
CONTEXT="${INPUT_CONTEXT}"
else
CONTEXT=.
fi
set -- "$@" --context "dir://${CONTEXT}"
if [ "${INPUT_PUSH}" = "false" ]
then
set -- "$@" --no-push
fi
if [ "${INPUT_CACHE}" = "true" ] && [ -n "${INPUT_CACHE_REPO}" ]
then
COMMAND="${COMMAND} --cache=true --cache-repo ${INPUT_CACHE_REPO}"
set -- "$@" --cache=true --cache-repo "${INPUT_CACHE_REPO}"
if [ -n "${INPUT_CACHE_TTL}" ]
then
set -- "$@" --cache-ttl="${INPUT_CACHE_TTL}"
fi
fi
if [ -n "${INPUT_DESTINATIONS}" ]
then
for DESTINATION in ${INPUT_DESTINATIONS}
do
set -- "$@" --destination "${DESTINATION}"
done
fi
if [ -d "${CONTEXT}/LICENSES" ]
then
licenses=""
for l in LICENSES/*;
do
license=$(basename "$l" .txt)
if [ -z "${licenses}" ]
then
licenses="${license}"
else
licenses="${licenses} AND ${license}"
fi
done
set -- "$@" --label "org.opencontainers.image.licenses=${licenses}"
fi
if [ -n "${INPUT_VERSION}" ]
then
set -- "$@" --label "org.opencontainers.image.version=${INPUT_VERSION}"
fi
exec "$@"