From 8b5fa414d79b1fccd313b48f355381ac07e81b17 Mon Sep 17 00:00:00 2001 From: bartool Date: Wed, 29 Oct 2025 21:48:46 +0100 Subject: [PATCH] Add cron job setup and entrypoint script for scheduled task execution --- Dockerfile | 10 ++++++++-- crontab | 1 + entrypoint.sh | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 crontab create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index e2c6cec..4f930e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,17 @@ FROM python:3.9-slim-buster +# Install cron +RUN apt-get update && apt-get -y install cron + WORKDIR /app COPY requirements.txt . - RUN pip install --no-cache-dir -r requirements.txt COPY . . -CMD ["python", "main.py"] +# Make entrypoint script executable +RUN chmod +x /app/entrypoint.sh + +# Set the entrypoint +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/crontab b/crontab new file mode 100644 index 0000000..2ef3a1c --- /dev/null +++ b/crontab @@ -0,0 +1 @@ +0 8 * * * python /app/main.py >> /var/log/cron.log 2>&1 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b233ae6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Load the cron job +crontab /app/crontab + +# Create the log file and set permissions +touch /var/log/cron.log +chmod 0666 /var/log/cron.log + +# Start cron in the foreground +cron -f