From 4b8963b7bac999e2effb9840b01c9c01b8218fc0 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Tue, 9 Nov 2021 00:29:19 -0800 Subject: [PATCH] feat(docker): add cron service (aurblup + mkpkglists) Normally, these scripts are used to update official providers in the aurweb database along with archives that can be retrieved. Run both of these scripts in a 5 minute cron job, to both reflect the live instance database and production load. Signed-off-by: Kevin Morris --- docker-compose.yml | 17 +++++++++++++++++ docker/config/aurweb-cron | 2 ++ docker/cron-entrypoint.sh | 16 ++++++++++++++++ docker/scripts/install-deps.sh | 2 +- docker/scripts/run-cron.sh | 7 +++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 docker/config/aurweb-cron create mode 100755 docker/cron-entrypoint.sh create mode 100755 docker/scripts/run-cron.sh diff --git a/docker-compose.yml b/docker-compose.yml index 038eb65b..c2b14f91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -144,6 +144,19 @@ services: volumes: - git_data:/aurweb/aur.git + cron: + image: aurweb:latest + init: true + environment: + - AUR_CONFIG=/aurweb/conf/config + entrypoint: /docker/cron-entrypoint.sh + command: /docker/scripts/run-cron.sh + depends_on: + mariadb_init: + condition: service_started + volumes: + - mariadb_run:/var/run/mysqld + php-fpm: image: aurweb:latest init: true @@ -163,6 +176,8 @@ services: condition: service_healthy memcached: condition: service_healthy + cron: + condition: service_started volumes: - mariadb_run:/var/run/mysqld ports: @@ -190,6 +205,8 @@ services: condition: service_healthy redis: condition: service_healthy + cron: + condition: service_started volumes: - mariadb_run:/var/run/mysqld ports: diff --git a/docker/config/aurweb-cron b/docker/config/aurweb-cron new file mode 100644 index 00000000..1be7c13c --- /dev/null +++ b/docker/config/aurweb-cron @@ -0,0 +1,2 @@ +*/5 * * * * aurweb-aurblup +*/5 * * * * aurweb-mkpkglists diff --git a/docker/cron-entrypoint.sh b/docker/cron-entrypoint.sh new file mode 100755 index 00000000..d4173eaf --- /dev/null +++ b/docker/cron-entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eou pipefail + +# Prepare AUR_CONFIG. +cp -vf conf/config.dev conf/config +sed -i "s;YOUR_AUR_ROOT;$(pwd);g" conf/config + +# Create directories we need. +mkdir -p /aurweb/aurblup + +# Install the cron configuration. +cp /docker/config/aurweb-cron /etc/cron.d/aurweb-cron +chmod 0644 /etc/cron.d/aurweb-cron +crontab /etc/cron.d/aurweb-cron + +exec "$@" diff --git a/docker/scripts/install-deps.sh b/docker/scripts/install-deps.sh index 52ad6747..d64340e3 100755 --- a/docker/scripts/install-deps.sh +++ b/docker/scripts/install-deps.sh @@ -8,7 +8,7 @@ pacman -Syu --noconfirm --noprogressbar \ --cachedir .pkg-cache git gpgme nginx redis openssh \ mariadb mariadb-libs cgit-aurweb uwsgi uwsgi-plugin-cgi \ php php-fpm memcached php-memcached python-pip pyalpm \ - python-srcinfo curl libeatmydata + python-srcinfo curl libeatmydata cronie # https://python-poetry.org/docs/ Installation section. curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - diff --git a/docker/scripts/run-cron.sh b/docker/scripts/run-cron.sh new file mode 100755 index 00000000..d927a790 --- /dev/null +++ b/docker/scripts/run-cron.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd /aurweb +aurweb-aurblup +aurweb-mkpkglists + +exec /usr/bin/crond -n