Skip to content

Commit

Permalink
Fixing entrypoint dealing with JSON mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar Ahmad committed Dec 23, 2020
1 parent 0ef54cc commit 88bed2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
30 changes: 10 additions & 20 deletions config-samples/config.sample.mapping.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,38 @@
[
{
{
"cron with triggered commands": {
"comment": "cron with triggered commands",
"schedule": "* * * * *",
"command": "echo hello",
"project": "crontab",
"container": "myapp",
"trigger": [
{
"command": "echo world",
"container": "crontab_myapp_1"
}
]
"trigger": [{ "command": "echo world", "container": "crontab_myapp_1" }]
},
{
"map a volume": {
"comment": "map a volume",
"schedule": "* * * * *",
"dockerargs": "-d -v /tmp:/tmp",
"command": "echo new",
"image": "alpine:3.5"
},
{
"use an ENV from inside a container": {
"comment": "use an ENV from inside a container",
"schedule": "@hourly",
"dockerargs": "-d -e FOO=BAR",
"command": "sh -c 'echo hourly ${FOO}'",
"image": "alpine:3.5"
},
{
"trigger every 2 min": {
"comment": "trigger every 2 min",
"schedule": "@every 2m",
"command": "echo 2 minute",
"image": "alpine:3.5",
"trigger": [
{
"command": "echo world",
"container": "crontab_myapp_1"
}
]
"trigger": [{ "command": "echo world", "container": "crontab_myapp_1" }]
},
{
"null": {
"schedule": "*/5 * * * *",
"command": "/usr/sbin/logrotate /etc/logrotate.conf"
},
{
"Regenerate Certificate then reload nginx": {
"comment": "Regenerate Certificate then reload nginx",
"schedule": "43 6,18 * * *",
"command": "sh -c 'dehydrated --cron --out /etc/ssl --domain ${LE_DOMAIN} --challenge dns-01 --hook dehydrated-dns'",
Expand All @@ -57,4 +47,4 @@
],
"onstart": true
}
]
}
10 changes: 5 additions & 5 deletions docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ fi

get_config() {
if [ -f "${HOME_DIR}/config.json" ]; then
cp ${HOME_DIR}/config.json ${HOME_DIR}/config.json.old
jq 'map(.)' ${HOME_DIR}/config.json.old > ${HOME_DIR}/config.json
rm ${HOME_DIR}/config.json.old
jq 'map(.)' ${HOME_DIR}/config.json > ${HOME_DIR}/config.working.json
elif [ -f "${HOME_DIR}/config.toml" ]; then
rq -t <<< $(cat ${HOME_DIR}/config.toml) | jq 'map(.)' > ${HOME_DIR}/config.json
elif [ -f "${HOME_DIR}/config.yml" ]; then
Expand Down Expand Up @@ -265,8 +263,10 @@ ensure_docker_socket_accessible

start_app() {
get_config
if [ -f "${HOME_DIR}/config.json" ]; then
export CONFIG=${HOME_DIR}/config.json
if [ -f "${HOME_DIR}/config.working.json" ]; then
export CONFIG=${HOME_DIR}/config.working.json
elif [ -f "${HOME_DIR}/config.json" ]; then
export CONFIG=${HOME_DIR}/config.json
else
echo "NO CONFIG FILE FOUND"
fi
Expand Down

0 comments on commit 88bed2b

Please sign in to comment.