mirror of
https://github.com/willfarrell/docker-crontab.git
synced 2025-04-04 14:05:11 +02:00
using tini, functions for most code in entrypoint
This commit is contained in:
parent
4a0d85f51a
commit
4f9146b8f8
@ -1,12 +1,12 @@
|
||||
FROM library/docker:stable
|
||||
|
||||
ENV HOME_DIR=/opt/crontab
|
||||
RUN apk add --no-cache --virtual .run-deps gettext bash py3-toml py3-yaml python3 jq \
|
||||
RUN apk add --no-cache --virtual .run-deps gettext bash py3-toml py3-yaml python3 jq tini \
|
||||
&& mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects \
|
||||
&& adduser -S docker -D
|
||||
|
||||
COPY docker-entrypoint /
|
||||
ENTRYPOINT ["/docker-entrypoint"]
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/docker-entrypoint"]
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s \
|
||||
CMD ps aux | grep '[c]rond' || exit 1
|
||||
|
@ -15,7 +15,7 @@ if [ "${LOG_FILE}" == "" ]; then
|
||||
touch ${LOG_FILE}
|
||||
fi
|
||||
|
||||
|
||||
get_config() {
|
||||
if [ -f "${HOME_DIR}/config.toml" ]; then
|
||||
python3 -c "with open('${HOME_DIR}/config.toml') as ct, open('${HOME_DIR}/config.json', 'w') as cj: import toml; import json; json.dump(list(toml.load(ct).values()), cj)"
|
||||
elif [ -f "${HOME_DIR}/config.yml" ]; then
|
||||
@ -23,12 +23,7 @@ elif [ -f "${HOME_DIR}/config.yml" ]; then
|
||||
elif [ -f "${HOME_DIR}/config.yaml" ]; then
|
||||
python3 -c "with open('${HOME_DIR}/config.yaml') as cy, open('${HOME_DIR}/config.json', 'w') as cj: import yaml; import json; json.dump(list(yaml.safe_load(cy).values()), cj)"
|
||||
fi
|
||||
|
||||
if [ -f "${HOME_DIR}/config.json" ]; then
|
||||
CONFIG=${HOME_DIR}/config.json
|
||||
else
|
||||
echo "NO CONFIG FILE FOUND"
|
||||
fi
|
||||
}
|
||||
|
||||
DOCKER_SOCK=/var/run/docker.sock
|
||||
CRONTAB_FILE=/etc/crontabs/docker
|
||||
@ -183,6 +178,7 @@ parse_schedule() {
|
||||
}
|
||||
|
||||
function build_crontab() {
|
||||
|
||||
rm -rf ${CRONTAB_FILE}
|
||||
|
||||
ONSTART=()
|
||||
@ -260,8 +256,16 @@ EOF
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
ensure_docker_socket_accessible
|
||||
|
||||
start_app() {
|
||||
get_config
|
||||
if [ -f "${HOME_DIR}/config.json" ]; then
|
||||
export CONFIG=${HOME_DIR}/config.json
|
||||
else
|
||||
echo "NO CONFIG FILE FOUND"
|
||||
fi
|
||||
if [ "$1" = "crond" ]; then
|
||||
if [ -f ${CONFIG} ]; then
|
||||
build_crontab
|
||||
@ -269,6 +273,8 @@ if [ "$1" = "crond" ]; then
|
||||
echo "Unable to find ${CONFIG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$@"
|
||||
exec "$@"
|
||||
}
|
||||
|
||||
start_app "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user