Commit 18665b71 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Disable running cron from the website

This should be both a speed improvement and a security one as well.
parent bd6f427d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
FROM php:7.3-fpm as deps
RUN apt-get update \
 && apt-get install -y \
    bash-builtins \
	libgmp10 \
	libjpeg62 \
	libpng16-16 \
+19 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@

set -eu -o pipefail
shopt -s nullglob globstar
enable -f /usr/lib/bash/sleep sleep

declare -a THEMES=() PLUGINS=() LANGUAGES=()
declare DB_HOST DB_NAME DB_USER DB_PASS
@@ -58,6 +59,12 @@ create_config()
		 */
		define('DISALLOW_FILE_MODS', true);

		/*
		 * Disable running wp-cron.php on every page load.
		 * Instead corn jobs will be run every 15 minutes.
		 */
		define('DISABLE_WP_CRON', true);

		/*
		 * Move the uploads volume/directory into the top of the Wordpress 
		 * installation.
@@ -95,7 +102,8 @@ setup() {

	[[ ${#THEMES[*]} -gt 0 ]] &&
	[[ $(wp theme list --status=active --format=count) -eq 0 ]] &&
	wp theme activate $(wp theme list --field=name | head -n1)
	wp theme activate $(wp theme list --field=name | head -n1) ||
	true
}

collect_static()
@@ -120,6 +128,14 @@ collect_static()
		. static/
}

run_cron()
{
	local interval=60
	while sleep $(wp cron schedule list --field=interval | head -n1); do
		wp cron event run --due-now
	done
}

for file in /etc/wordpress/**/*.conf; do
	source ${file}
done
@@ -138,10 +154,12 @@ case "$1" in
	database-setup) create_config -f && wp core install "${@:2}" ;;
	install-setup) create_config && setup ;;
	collect-static) create_config && collect_static ;;
	run-cron) create_config && run_cron ;;
	php-fpm)
		create_config
		setup
		collect_static
		run_cron &
		exec "$@"
		;;
	*)
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ server {
		return 404;
	}

	# block external cron triggers
	location = /wp-cron.php {
		return 404;
	}

	# allow the new JSON REST API
	location /wp-json/ {
		try_files /non-existant /index.php$is_args$args;