diff --git a/Dockerfile b/Dockerfile index 62728f5..861c0bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,5 +66,19 @@ RUN mkdir -p /var/www/moodledata && \ # chown -R www-data:www-data /var/www/moodledata && \ chmod -R 770 /var/www/moodledata + +# Set up Moodle cron job +COPY moodle-cron /etc/cron.d/moodle-cron +RUN chmod 0644 /etc/cron.d/moodle-cron && \ + crontab /etc/cron.d/moodle-cron + +# Create startup script to run cron and apache +COPY start.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/start.sh + # Set working directory WORKDIR /var/www/html + +# Set entrypoint to our startup script +ENTRYPOINT ["/usr/local/bin/start.sh"] + diff --git a/moodle-cron b/moodle-cron new file mode 100644 index 0000000..8ec581c --- /dev/null +++ b/moodle-cron @@ -0,0 +1,2 @@ +# Run Moodle cron every minute +* * * * * /usr/local/bin/php /var/www/html/admin/cli/cron.php > /dev/null 2>&1 \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..c545bbd --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Start cron service +service cron start + +# Start Apache in foreground +apache2-foreground \ No newline at end of file