Skip to content

Commit

Permalink
Better log output
Browse files Browse the repository at this point in the history
  • Loading branch information
waschinski committed Feb 8, 2024
1 parent 8cb8a87 commit 299b089
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
FROM python:3.12-alpine
FROM python:3.12-slim

# Update apt-get package list, grab pre-requisites 'cron' & 'vim'
RUN apt-get update && apt-get -y install cron vim

# Set the working directory for following commands in this docker container to '/app'
WORKDIR /app

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

# Make the crontab executable
RUN chmod 0644 /etc/cron.d/crontab
RUN /usr/bin/crontab /etc/cron.d/crontab

# run crond as main process of container
CMD ["/usr/sbin/crond", "-f", "-d", "0"]
# Set the cron job
RUN crontab /etc/cron.d/crontab

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

# Run cron and tail the log
CMD cron && tail -f /tmp/out.log
2 changes: 1 addition & 1 deletion crontab
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# START CRON JOB
* * * * * python3 /app/extract.py
*/5 * * * * /usr/local/bin/python /app/extract.py >>/tmp/out.log 2>&1
# END CRON JOB
2 changes: 2 additions & 0 deletions extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@

with open("/output/certs/key.pem", "w") as key_file:
key_file.write(key)

print("Cert extracted successfully.")

0 comments on commit 299b089

Please sign in to comment.