From 10b32da3e009582a3d0f8ade76d7ca175285f2e3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 20 Aug 2022 20:48:27 +0100 Subject: [PATCH] Add crontab to project Cron will likely be a duplicate compose service with a different command. --- .gitlab-ci.yml | 9 +++++++++ Dockerfile | 2 ++ etc/crontab | 4 ++++ website/settings.py | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 etc/crontab diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7f737f..67c28f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -132,3 +132,12 @@ pip_tools: - ./scripts/compile-requirements.sh - git diff - git diff-index --quiet HEAD -- + +crontab: + image: alpine + stage: test + dependencies: [] + before_script: + - apk add --no-cache supercronic + script: + - supercronic -test etc/crontab diff --git a/Dockerfile b/Dockerfile index b229e7d..34250c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,8 @@ RUN useradd website --create-home -u 1000 && mkdir /app $VIRTUAL_ENV && chown -R WORKDIR /app +RUN wget https://github.com/aptible/supercronic/releases/download/v0.2.1/supercronic-linux-amd64 -O /usr/local/bin/supercronic && chmod +x /usr/local/bin/supercronic + ENV PATH=${POETRY_HOME}/bin:$VIRTUAL_ENV/bin:$PATH \ PYTHONUNBUFFERED=1 diff --git a/etc/crontab b/etc/crontab new file mode 100644 index 0000000..7816329 --- /dev/null +++ b/etc/crontab @@ -0,0 +1,4 @@ +@weekly ./manage.py update_index +@daily ./manage.py clearsessions +@daily ./manage.py update_unsplash_photos +*/10 * * * * ./manage.py publish_scheduled_pages diff --git a/website/settings.py b/website/settings.py index 25e23a3..3589cf2 100644 --- a/website/settings.py +++ b/website/settings.py @@ -163,7 +163,7 @@ WAGTAIL_SITE_NAME = "website" WAGTAILSEARCH_BACKENDS = { "default": { "BACKEND": "wagtail.search.backends.database", - "AUTO_UPDATE": DEBUG, + "AUTO_UPDATE": True, "ATOMIC_REBUILD": True, } }