Skip to content

Commit

Permalink
feat: add scheduled tasks to PDFGen container
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Dec 2, 2021
1 parent 65d8000 commit 442ebba
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion doubtfire-api
4 changes: 4 additions & 0 deletions pdfGen/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
10,15,20,25,30,35,40,45,50,55 * * * * /doubtfire/lib/shell/generate_pdfs.sh
0 5 * * 1,3,5 /doubtfire/lib/shell/check_plagiarism.sh
0 7 * * 1 /doubtfire/lib/shell/send_weekly_emails.sh
0 1 * * * /doubtfire/lib/shell/sync_enrolments.sh
8 changes: 8 additions & 0 deletions pdfGen/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Ensure log is present
touch /var/log/cron.log
# Setup crontab
crontab /etc/cron.d/container_cronjob
# Run cron and follow log
chmod 644 /etc/cron.d/container_cronjob && cron && tail -f /var/log/cron.log”
10 changes: 8 additions & 2 deletions pdfgen.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM ruby:2.6.7-buster

ARG API_HOME=./doubtfire-api
ARG PDFGEN_HOME=./pdfGen

# Setup dependencies
ARG DEBIAN_FRONTEND=noninteractive
Expand All @@ -13,11 +14,15 @@ RUN apt-get update && apt-get install -y \
libmagickwand-dev \
libmariadb-dev \
python3-pygments \
tzdata
tzdata \
cron

# Setup the folder where we will deploy the code
WORKDIR /doubtfire

# Crontab file copied to cron.d directory.
COPY "$PDFGEN_HOME"/cronjob /etc/cron.d/container_cronjob

# Install LaTex
COPY "$API_HOME"/.ci-setup /doubtfire/.ci-setup
RUN /doubtfire/.ci-setup/texlive-install.sh
Expand All @@ -34,5 +39,6 @@ ENV PATH /tmp/texlive/bin/x86_64-linux:$PATH

# Copy doubtfire-api source
COPY "$API_HOME" /doubtfire/
COPY "$PDFGEN_HOME"/script.sh /doubtfire/

CMD bundle exec rake submission:generate_pdfs
CMD script.sh

0 comments on commit 442ebba

Please sign in to comment.