diora-web/Dockerfile.cron

22 lines
797 B
Text
Raw Permalink Normal View History

FROM python:3.12-slim
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends cron && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Write cron job: refresh podcast feeds every hour
# The job sources /etc/environment so Docker env vars (DB path, secret key etc.) are available.
RUN echo "0 * * * * root . /etc/environment; cd /app && python manage.py refresh_feeds >> /var/log/cron.log 2>&1" \
> /etc/cron.d/podcast-refresh && \
chmod 0644 /etc/cron.d/podcast-refresh && \
touch /var/log/cron.log
# Dump Docker env vars into /etc/environment at container start so cron jobs can read them,
# then launch vixie cron in foreground.
CMD ["bash", "-c", "printenv > /etc/environment && cron -f"]