diff --git a/config/config.yml b/config/config.yml index 897e68796239fe86184d2d5e1026a22eec432e4a..c972739e1dd18a28e45c930aceb5f3e2dd497d2b 100644 --- a/config/config.yml +++ b/config/config.yml @@ -67,4 +67,3 @@ PicoZCache: dir: content/cache/html/ # Directory where cache should be saved time: 2592000 # Interval between caching (period from one to second cache) in seconds, here is 7 days = 60 * 60 * 24 * 30. xhtml_output: false # If true, XHTML Content-Type header will be sent when loading cache page - ignore_url_regex: "/blog/" diff --git a/docker/Dockerfile b/docker/Dockerfile index 1d2d0ba2438bbbba998c7c6c2c05ee1c9d63ecf3..4c67873a54c469067369a0a354887ef2b6ae324f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ RUN composer create-project --no-interaction picocms/pico-composer pico FROM php:7.4-apache RUN apt-get update && \ - apt-get install -y libonig-dev libxml2-dev locales && \ + apt-get install -y inotify-tools libonig-dev libxml2-dev locales && \ docker-php-ext-install -j$(nproc) dom mbstring && \ docker-php-ext-enable dom mbstring @@ -19,3 +19,9 @@ COPY --from=builder /app/pico /var/www/html RUN a2enmod rewrite COPY pico.conf /etc/apache2/sites-enabled/000-default.conf + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT /entrypoint.sh diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..518190d7259dcc6c5b22aac0216a794b72811a0a --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +basedir=/var/www/html +cachedir=$basedir/content/cache +clear_cache() { + echo "Clearing HTML cache" + rm -rf $cachedir/html/* + echo "Clearing TWIG cache" + rm -rf $cachedir/twig/* +} +watcher() { + clear_cache + inotifywait -m -r -e modify -e move -e create -e delete \ + --exclude '\.*.sw?' \ + --exclude $cachedir \ + $basedir |\ + while read dir ev file; do + echo "File $ev detected" + clear_cache + done +} +watcher & +exec apache2ctl -DFOREGROUND