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