Add cron job setup and entrypoint script for scheduled task execution

This commit is contained in:
2025-10-29 21:48:46 +01:00
parent 0412ca1321
commit 8b5fa414d7
3 changed files with 20 additions and 2 deletions

View File

@@ -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"]

1
crontab Normal file
View File

@@ -0,0 +1 @@
0 8 * * * python /app/main.py >> /var/log/cron.log 2>&1

11
entrypoint.sh Normal file
View File

@@ -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