Add entrypoint.sh
This commit is contained in:
parent
058c26ed51
commit
fb2f8f6589
1 changed files with 83 additions and 0 deletions
83
entrypoint.sh
Normal file
83
entrypoint.sh
Normal 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 "$@"
|
Loading…
Reference in a new issue