Created
March 17, 2023 09:22
-
-
Save jamesmurdza/6a6c713dfe7fd700f8400e75adcbe604 to your computer and use it in GitHub Desktop.
Dockerfile for a scheduled Python script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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