Skip to content

Commit 7740a35

Browse files
committed
Environment configurable cron
1 parent 6b2222c commit 7740a35

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

cron-entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env sh
2+
3+
# Exit immediately if a command exits with a failure status
4+
set -e
5+
6+
# Set default values for environment variables controlling the cron schedule
7+
BOOTSTRAP_SCHEDULE=${BOOTSTRAP_SCHEDULE:-"*/5 * * * *"}
8+
HELLO_SCHEDULE=${HELLO_SCHEDULE:-"*/15 * * * * * *"}
9+
10+
# Create the supercronic crontab file
11+
echo "${BOOTSTRAP_SCHEDULE} java -cp application.jar io.github.raniagus.example.bootstrap.Bootstrap" > ./crontab
12+
echo "${HELLO_SCHEDULE} echo 'Hello from supercronic!'" >> ./crontab
13+
14+
# Run supercronic with the created crontab file
15+
supercronic "$@" ./crontab

cron.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ WORKDIR /home/appuser
3434

3535
COPY --from=builder /build/target/*-with-dependencies.jar ./application.jar
3636

37-
COPY crontab .
37+
COPY cron-entrypoint.sh .
3838

39-
ENTRYPOINT ["supercronic", "-passthrough-logs", "crontab"]
39+
ENTRYPOINT ["sh", "cron-entrypoint.sh"]
40+
CMD ["-passthrough-logs"]

crontab

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)