Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
FROM python:3.7
FROM python:3.10

RUN apt-get update && apt-get -y install cron vim

WORKDIR /app

COPY crontab /etc/cron.d/crontab
COPY hello.py /app/hello.py

RUN chmod 0644 /etc/cron.d/crontab
RUN /usr/bin/crontab /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab

# Create a virtual environment
RUN python -m venv /opt/venv

# run crond as main process of container
CMD ["cron", "-f"]
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"

# Create empty log (TAIL needs this)
RUN touch /tmp/out.log

# Run cron and tail the log
CMD cron && tail -f /tmp/out.log
4 changes: 2 additions & 2 deletions crontab
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# START CRON JOB
* * * * * python /app/hello.py > /proc/1/fd/1 2>/proc/1/fd/2
# END CRON JOB
* * * * * python3 /app/hello.py >>/tmp/out.log 2>/tmp/err.log
# END CRON JOB