Skip to content

Commit 918dcab

Browse files
coliseeRobin Alexander
andauthored
Replace cron with supercronic (#185)
* Issue 183: replace cron with supercronic * Issue 183: stop redirecting output of crontab jobs * Issue 183: use the same entrypoint for app and job containers * Issue 183: we now use the command override to specify the container role * Issue 183: Implement recommendation from hadolint * Issue 183: Apply recommendations from Copilot --------- Co-authored-by: Robin Alexander <colisee@hotmail>
1 parent 73fad1b commit 918dcab

7 files changed

Lines changed: 24 additions & 74 deletions

File tree

.examples/docker/docker-compose-local.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ services:
2222
cron:
2323
image: librebooking/librebooking:develop
2424
restart: always
25-
user: root
26-
entrypoint: /usr/local/bin/cron.sh
25+
command: supercronic /config/lb-jobs-cron
2726
depends_on:
2827
- app
2928
volumes:

.examples/docker/docker-compose-public.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ services:
5858
restart: always
5959
depends_on:
6060
- lb1
61-
user: root
62-
entrypoint: /usr/local/bin/cron.sh
61+
command: supercronic /config/lb-jobs-cron
6362
volumes:
6463
- lb1_conf:/config
6564
env_file:
@@ -89,8 +88,7 @@ services:
8988
restart: always
9089
depends_on:
9190
- lb2
92-
user: root
93-
entrypoint: /usr/local/bin/cron.sh
91+
command: supercronic /config/lb-jobs-cron
9492
volumes:
9593
- lb2_conf:/config
9694
env_file:

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ fi
2121
rm -rf .git
2222
EORUN
2323

24+
# Build supercronic
25+
FROM golang:trixie AS supercronic
26+
ADD https://github.com/aptible/supercronic.git#v0.2.44 src
27+
WORKDIR /go/src
28+
RUN <<EORUN
29+
set -eux
30+
go mod vendor
31+
go install
32+
EORUN
33+
2434
FROM php:${VERSION_PHP}-apache
2535
# Labels
2636
LABEL org.opencontainers.image.title="LibreBooking"
@@ -40,6 +50,10 @@ COPY --chown=www-data:www-data --chmod=0755 \
4050
# Copy composer
4151
COPY --from=comp /usr/bin/composer /usr/bin/composer
4252

53+
# Copy supercronic
54+
COPY --from=supercronic \
55+
/go/bin/supercronic /usr/local/bin/supercronic
56+
4357
# Copy Librebooking
4458
COPY --from=upstream \
4559
--chown=www-data:root --chmod=0775 \

RUN.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ scheduler. For a full list of background jobs, checkout the
6060
The background jobs can either be handled by the:
6161

6262
* Container itself, by running a separate `librebooking/librebooking` container
63-
where the:
64-
65-
* user is set to `root`
66-
* entrypoint is set to `cron.sh`
63+
where the command is set to `supercronic /config/lb-jobs-cron`
6764

6865
* Host running the container, by calling the desired script, as in
6966

bin/cron.sh

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

lb-jobs-cron

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/autorelease.php > /dev/stdout 2>&1
2-
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendmissedcheckin.php > /dev/stdout 2>&1
3-
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendreminders.php > /dev/stdout 2>&1
4-
0 0 * * * /usr/local/bin/php -f /var/www/html/Jobs/sendseriesend.php > /dev/stdout 2>&1
5-
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendwaitlist.php > /dev/stdout 2>&1
6-
0 0 * * * /usr/local/bin/php -f /var/www/html/Jobs/sessioncleanup.php > /dev/stdout 2>&1
1+
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/autorelease.php
2+
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendmissedcheckin.php
3+
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendreminders.php
4+
0 0 * * * /usr/local/bin/php -f /var/www/html/Jobs/sendseriesend.php
5+
* * * * * /usr/local/bin/php -f /var/www/html/Jobs/sendwaitlist.php
6+
0 0 * * * /usr/local/bin/php -f /var/www/html/Jobs/sessioncleanup.php

setup.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ set -x
1212
apt-get update
1313
apt-get upgrade --yes
1414
apt-get install --yes --no-install-recommends \
15-
cron \
1615
libjpeg-dev \
1716
libldap-dev \
1817
libpng-dev \

0 commit comments

Comments
 (0)