Skip to content

Instantly share code, notes, and snippets.

@jamesmurdza
Created March 17, 2023 09:22
Show Gist options
  • Select an option

  • Save jamesmurdza/6a6c713dfe7fd700f8400e75adcbe604 to your computer and use it in GitHub Desktop.

Select an option

Save jamesmurdza/6a6c713dfe7fd700f8400e75adcbe604 to your computer and use it in GitHub Desktop.
Dockerfile for a scheduled Python script
FROM amancevice/pandas:1.4.4
WORKDIR /app
# Copy the Python application.
COPY requirements.txt .
COPY app.py .
# Install all dependencies for the Python application.
RUN pip install -r requirements.txt
# Setup cron and a cronjob to call the Python application.
# To customize the schedule, modify the *s below using crontab-generator.org.
RUN echo "* * * * * /usr/local/bin/python /app/app.py >> /app/logs/cron.log 2>&1" > mycron
RUN apt-get update
RUN apt-get install -y cron
RUN crontab mycron
# When the container runs, start cron and print logs.
RUN mkdir logs
CMD cron && tail -f --retry -s 10 logs/cron.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment