Skip to content

Commit 60db050

Browse files
committed
feat: execute wp crons every minute
1 parent 2782e83 commit 60db050

5 files changed

Lines changed: 24 additions & 0 deletions

File tree

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ ARG FLAVOR=apache
77

88
FROM ghcr.io/mlocati/php-extension-installer:2.7.24 AS ext-installer
99

10+
FROM --platform=$BUILDPLATFORM alpine AS supercronic
11+
ARG SUPERCRONIC_VERSION=v0.2.45
12+
ARG TARGETARCH
13+
RUN wget -O /usr/local/bin/supercronic "https://github.com/aptible/supercronic/releases/download/${SUPERCRONIC_VERSION}/supercronic-linux-${TARGETARCH}" \
14+
&& chmod +x /usr/local/bin/supercronic
15+
1016
FROM wordpress:cli-${CLI_VERSION}-php${PHP_VERSION} AS wp-cli-source
1117

1218
FROM wordpress:${WORDPRESS_VERSION}-php${PHP_VERSION}-${FLAVOR} AS base
@@ -26,6 +32,7 @@ EOT
2632

2733
FROM base
2834

35+
COPY --from=supercronic /usr/local/bin/supercronic /usr/local/bin/supercronic
2936
COPY --from=wp-cli-source /usr/local/bin/wp /usr/local/bin/wp
3037
ENV WP_CLI_ALLOW_ROOT=1
3138
ENV PAGER=cat
@@ -49,6 +56,10 @@ RUN <<EOT
4956
php.ini-production
5057

5158
ln -s php.ini-production php.ini
59+
60+
apt-get update
61+
apt-get install -y s6
62+
rm -rf /var/lib/apt/lists/*
5263
EOT
5364

5465
ENV PHP_MAX_EXECUTION_TIME=30
@@ -65,3 +76,7 @@ EOT
6576

6677
COPY --from=config-file /wp-config-docker.php /usr/src/wordpress/wp-config-docker.php
6778
COPY --chown=www-data:www-data wp-content /usr/src/wordpress/wp-content
79+
COPY rootfs /
80+
81+
ENTRYPOINT []
82+
CMD ["/usr/bin/s6-svscan", "/etc/s6/services"]

rootfs/etc/s6/services/apache/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd /var/www/html
3+
exec docker-entrypoint.sh apache2-foreground

rootfs/etc/s6/services/cron/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
cd /var/www/html
3+
exec s6-setuidgid www-data supercronic --quiet /etc/supercronic/wordpress

rootfs/etc/supercronic/wordpress

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* * * * * wp cron event run --due-now

wp-config.ext.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
define('DISABLE_WP_CRON', getenv_docker('DISABLE_WP_CRON', true));
2+
13
/* C3 Cloudfront Clear Cache envs */
24
define('AWS_ACCESS_KEY_ID', getenv_docker('AWS_ACCESS_KEY_ID', null));
35
define('AWS_SECRET_ACCESS_KEY', getenv_docker('AWS_SECRET_ACCESS_KEY', null));

0 commit comments

Comments
 (0)