Skip to content

Commit 88bed2b

Browse files
author
Omar Ahmad
committed
Fixing entrypoint dealing with JSON mapping
1 parent 0ef54cc commit 88bed2b

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed
+10-20
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
1-
[
2-
{
1+
{
2+
"cron with triggered commands": {
33
"comment": "cron with triggered commands",
44
"schedule": "* * * * *",
55
"command": "echo hello",
66
"project": "crontab",
77
"container": "myapp",
8-
"trigger": [
9-
{
10-
"command": "echo world",
11-
"container": "crontab_myapp_1"
12-
}
13-
]
8+
"trigger": [{ "command": "echo world", "container": "crontab_myapp_1" }]
149
},
15-
{
10+
"map a volume": {
1611
"comment": "map a volume",
1712
"schedule": "* * * * *",
1813
"dockerargs": "-d -v /tmp:/tmp",
1914
"command": "echo new",
2015
"image": "alpine:3.5"
2116
},
22-
{
17+
"use an ENV from inside a container": {
2318
"comment": "use an ENV from inside a container",
2419
"schedule": "@hourly",
2520
"dockerargs": "-d -e FOO=BAR",
2621
"command": "sh -c 'echo hourly ${FOO}'",
2722
"image": "alpine:3.5"
2823
},
29-
{
24+
"trigger every 2 min": {
3025
"comment": "trigger every 2 min",
3126
"schedule": "@every 2m",
3227
"command": "echo 2 minute",
3328
"image": "alpine:3.5",
34-
"trigger": [
35-
{
36-
"command": "echo world",
37-
"container": "crontab_myapp_1"
38-
}
39-
]
29+
"trigger": [{ "command": "echo world", "container": "crontab_myapp_1" }]
4030
},
41-
{
31+
"null": {
4232
"schedule": "*/5 * * * *",
4333
"command": "/usr/sbin/logrotate /etc/logrotate.conf"
4434
},
45-
{
35+
"Regenerate Certificate then reload nginx": {
4636
"comment": "Regenerate Certificate then reload nginx",
4737
"schedule": "43 6,18 * * *",
4838
"command": "sh -c 'dehydrated --cron --out /etc/ssl --domain ${LE_DOMAIN} --challenge dns-01 --hook dehydrated-dns'",
@@ -57,4 +47,4 @@
5747
],
5848
"onstart": true
5949
}
60-
]
50+
}

docker-entrypoint

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ fi
1717

1818
get_config() {
1919
if [ -f "${HOME_DIR}/config.json" ]; then
20-
cp ${HOME_DIR}/config.json ${HOME_DIR}/config.json.old
21-
jq 'map(.)' ${HOME_DIR}/config.json.old > ${HOME_DIR}/config.json
22-
rm ${HOME_DIR}/config.json.old
20+
jq 'map(.)' ${HOME_DIR}/config.json > ${HOME_DIR}/config.working.json
2321
elif [ -f "${HOME_DIR}/config.toml" ]; then
2422
rq -t <<< $(cat ${HOME_DIR}/config.toml) | jq 'map(.)' > ${HOME_DIR}/config.json
2523
elif [ -f "${HOME_DIR}/config.yml" ]; then
@@ -265,8 +263,10 @@ ensure_docker_socket_accessible
265263

266264
start_app() {
267265
get_config
268-
if [ -f "${HOME_DIR}/config.json" ]; then
269-
export CONFIG=${HOME_DIR}/config.json
266+
if [ -f "${HOME_DIR}/config.working.json" ]; then
267+
export CONFIG=${HOME_DIR}/config.working.json
268+
elif [ -f "${HOME_DIR}/config.json" ]; then
269+
export CONFIG=${HOME_DIR}/config.json
270270
else
271271
echo "NO CONFIG FILE FOUND"
272272
fi

0 commit comments

Comments
 (0)