From 10a1331e2249dc317392e3fa58bc720c1c074184 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Thu, 5 Dec 2024 16:00:57 -0300 Subject: [PATCH] Add scheduled task support to Dockerfile via cron --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4fb922c..31ca5b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,8 @@ RUN apk add --no-cache \ libffi \ libxml2 \ libxslt \ - tzdata + tzdata \ + dcron COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10 COPY --from=builder /app /app @@ -38,3 +39,7 @@ COPY --from=builder /app /app ENV PYTHONPATH=/usr/local/lib/python3.10/site-packages COPY . . + +RUN echo -e "SHELL=/bin/sh\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n" > /etc/crontabs/root + +CMD echo "${CRON:-0 0 * * *} python /app/cleanmedia.py ${CLEANMEDIA_OPTS:--t 30}" >> /etc/crontabs/root && crond -f -l 2