Skip to content

Commit fcf80e3

Browse files
committed
feat: add experimental builds support
- Add experimental section in versions.json for manual builds - Update matrix.sh to include experimental builds - Add apache-event-fpm variant based on docker-php:8.3-event-fpm
1 parent 1c0d1e2 commit fcf80e3

File tree

9 files changed

+342
-3
lines changed

9 files changed

+342
-3
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM inrage/docker-php:8.3-event-fpm
2+
3+
USER root
4+
5+
RUN set -ex; \
6+
\
7+
cd /tmp; \
8+
wp_cli_version="2.12.0"; \
9+
url="https://github.com/wp-cli/wp-cli/releases/download/v${wp_cli_version}/wp-cli-${wp_cli_version}.phar"; \
10+
curl -o wp.phar -fSL "${url}"; \
11+
chmod +x wp.phar; \
12+
mv wp.phar /usr/local/bin/wp; \
13+
\
14+
url="https://raw.githubusercontent.com/wp-cli/wp-cli/v${wp_cli_version}/utils/wp-completion.bash"; \
15+
curl -o /usr/local/include/wp-completion.bash -fSL "${url}"; \
16+
chmod +x /usr/local/include/wp-completion.bash; \
17+
cd /home/inr; \
18+
echo "source /usr/local/include/wp-completion.bash" | tee -a .bash_profile .bashrc;
19+
20+
USER inr
21+
22+
COPY templates /etc/gotpl/
23+
COPY bin /usr/local/bin
24+
25+
COPY init /docker-entrypoint-init.d/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
source=$1
6+
target=$2
7+
8+
/usr/local/bin/wp search-replace "${source}" "${target}" --format=count --all-tables --precise --skip-columns=guid
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
# -----------------------------------------------------------------------------
4+
# 00-presets.sh
5+
# Centralized performance profile management (WP_PRESET)
6+
# -----------------------------------------------------------------------------
7+
8+
# If WP_PRESET is not defined, default to 'vitrine'
9+
WP_PRESET=${WP_PRESET:-vitrine}
10+
11+
echo "🔧 [Init] Loading configuration preset: [$WP_PRESET]"
12+
13+
case "$WP_PRESET" in
14+
"high-traffic")
15+
# --- MODE: HIGH TRAFFIC / SALES / NEWSLETTER ---
16+
# Goal: Max availability. Never crash, never flush cache on boot.
17+
18+
# 1. Cache Safety (Used by scripts 10 and 20)
19+
export SKIP_CACHE_FLUSH=${SKIP_CACHE_FLUSH:-true}
20+
21+
# 2. Apache Tuning (Used by docker-php)
22+
# We override default values ONLY if they are not explicitly set in docker-compose
23+
export APACHE_MPM_START_SERVERS=${APACHE_MPM_START_SERVERS:-10}
24+
export APACHE_MPM_MIN_SPARE_SERVERS=${APACHE_MPM_MIN_SPARE_SERVERS:-10}
25+
export APACHE_MPM_MAX_SPARE_SERVERS=${APACHE_MPM_MAX_SPARE_SERVERS:-20}
26+
export APACHE_MPM_MAX_REQUEST_WORKERS=${APACHE_MPM_MAX_REQUEST_WORKERS:-50}
27+
export APACHE_MPM_MAX_CONNECTIONS_PER_CHILD=${APACHE_MPM_MAX_CONNECTIONS_PER_CHILD:-3000}
28+
29+
# 3. PHP Tuning
30+
export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-512M}
31+
# Max Performance: stop scanning disk for PHP file changes
32+
export PHP_OPCACHE_VALIDATE_TIMESTAMPS=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-0}
33+
export PHP_OPCACHE_MAX_ACCELERATED_FILES=${PHP_OPCACHE_MAX_ACCELERATED_FILES:-60000}
34+
export PHP_OPCACHE_MEMORY_CONSUMPTION=${PHP_OPCACHE_MEMORY_CONSUMPTION:-512}
35+
;;
36+
37+
"woocommerce")
38+
# --- MODE: STANDARD E-COMMERCE ---
39+
# Goal: Stability and RAM, but standard cache flush for updates.
40+
41+
export SKIP_CACHE_FLUSH=${SKIP_CACHE_FLUSH:-false}
42+
43+
export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-512M}
44+
export PHP_OPCACHE_VALIDATE_TIMESTAMPS=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}
45+
46+
export APACHE_MPM_START_SERVERS=${APACHE_MPM_START_SERVERS:-5}
47+
export APACHE_MPM_MIN_SPARE_SERVERS=${APACHE_MPM_MIN_SPARE_SERVERS:-5}
48+
export APACHE_MPM_MAX_SPARE_SERVERS=${APACHE_MPM_MAX_SPARE_SERVERS:-10}
49+
export APACHE_MPM_MAX_REQUEST_WORKERS=${APACHE_MPM_MAX_REQUEST_WORKERS:-25}
50+
;;
51+
52+
"vitrine-heavy")
53+
# --- MODE: LARGE CORPORATE SITE ---
54+
# Goal: Asset delivery, moderate traffic.
55+
56+
export SKIP_CACHE_FLUSH=${SKIP_CACHE_FLUSH:-false}
57+
export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-256M}
58+
export APACHE_MPM_MAX_REQUEST_WORKERS=${APACHE_MPM_MAX_REQUEST_WORKERS:-25}
59+
;;
60+
61+
*)
62+
# --- MODE: VITRINE / DEFAULT ---
63+
# Goal: Resource economy.
64+
65+
export SKIP_CACHE_FLUSH=${SKIP_CACHE_FLUSH:-false}
66+
67+
export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-128M}
68+
export PHP_OPCACHE_VALIDATE_TIMESTAMPS=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}
69+
70+
export APACHE_MPM_START_SERVERS=${APACHE_MPM_START_SERVERS:-2}
71+
export APACHE_MPM_MIN_SPARE_SERVERS=${APACHE_MPM_MIN_SPARE_SERVERS:-2}
72+
export APACHE_MPM_MAX_SPARE_SERVERS=${APACHE_MPM_MAX_SPARE_SERVERS:-5}
73+
export APACHE_MPM_MAX_REQUEST_WORKERS=${APACHE_MPM_MAX_REQUEST_WORKERS:-10}
74+
;;
75+
esac
76+
77+
echo "✅ [Init] Configuration applied for preset '$WP_PRESET'."
78+
echo " - Workers: $APACHE_MPM_MAX_REQUEST_WORKERS"
79+
echo " - Skip Flush: $SKIP_CACHE_FLUSH"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
start_redis() {
6+
if wp redis &>/dev/null; then
7+
echo "Redis is installed... enabling Redis object cache..."
8+
wp redis enable --force
9+
else
10+
echo "Redis is not installed... skipping Redis commands."
11+
fi
12+
}
13+
14+
_gotpl() {
15+
if [[ -f "/etc/gotpl/$1" ]]; then
16+
gotpl "/etc/gotpl/$1" >"$2"
17+
fi
18+
}
19+
20+
if [[ "${WORDPRESS_NO_CREATE_CONFIG}" != "true" ]]; then
21+
_gotpl "wp-config.php.tmpl" "/var/www/html/wp-config.php"
22+
fi
23+
24+
CONTENT_DIR=$(wp eval 'echo WP_CONTENT_DIR;')
25+
26+
mkdir -p "${CONTENT_DIR}/mu-plugins"
27+
_gotpl "production.php.tmpl" "${CONTENT_DIR}/mu-plugins/production.php"
28+
29+
## Create upgrade directory
30+
if [[ ! -d "${CONTENT_DIR}/upgrade" ]]; then
31+
mkdir -p "${CONTENT_DIR}/upgrade"
32+
fi
33+
34+
start_redis
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if wp acorn &>/dev/null; then
6+
echo "wp acorn command is available"
7+
8+
echo "Clearing Acorn and optimize..."
9+
wp acorn optimize
10+
11+
# Run wp acorn view:cache command
12+
echo "Running wp acorn icons:cache..."
13+
if wp acorn icons &>/dev/null; then
14+
echo "wp acorn icons command is available"
15+
if ! wp acorn icons:cache; then
16+
echo "Failed to cache icons" >&2
17+
exit 1
18+
fi
19+
else
20+
echo "wp acorn icons command is not available... skipping Acorn commands."
21+
fi
22+
else
23+
echo "project is not using Acorn or Acorn is not installed... skipping Acorn commands."
24+
fi
25+
26+
if wp cache &>/dev/null; then
27+
echo "wp cache command is available"
28+
29+
# Run wp cache flush command
30+
if [ "${SKIP_CACHE_FLUSH:-false}" = "true" ]; then
31+
echo "⚡ SKIP_CACHE_FLUSH is enabled : The existing cache is retained (High-Traffic Mode)."
32+
else
33+
echo "Flushing cache..."
34+
if ! wp cache flush; then
35+
echo "Failed to flush cache" >&2
36+
fi
37+
fi
38+
else
39+
echo "project is not using cache or cache is not installed... skipping cache commands."
40+
fi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
add_filter('site_status_tests', function ($tests) {
4+
unset($tests['async']['background_updates']);
5+
6+
return $tests;
7+
}, 100);
8+
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* The base configuration for WordPress
4+
*
5+
* The wp-config.php creation script uses this file during the installation.
6+
* You don't have to use the web site, you can copy this file to "wp-config.php"
7+
* and fill in the values.
8+
*
9+
* This file contains the following configurations:
10+
*
11+
* * Database settings
12+
* * Secret keys
13+
* * Database table prefix
14+
* * ABSPATH
15+
*
16+
* This has been slightly modified (to read environment variables) for use in Docker.
17+
*
18+
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
19+
*
20+
* @package WordPress
21+
*/
22+
23+
// IMPORTANT: this file needs to stay in-sync with https://github.com/WordPress/WordPress/blob/master/wp-config-sample.php
24+
// (it gets parsed by the upstream wizard in https://github.com/WordPress/WordPress/blob/f27cb65e1ef25d11b535695a660e7282b98eb742/wp-admin/setup-config.php#L356-L392)
25+
26+
// a helper function to lookup "env_FILE", "env", then fallback
27+
if (!function_exists('getenv_docker')) {
28+
// https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
29+
function getenv_docker($env, $default) {
30+
if ($fileEnv = getenv($env . '_FILE')) {
31+
return rtrim(file_get_contents($fileEnv), "\r\n");
32+
}
33+
else if (($val = getenv($env)) !== false) {
34+
return $val;
35+
}
36+
else {
37+
return $default;
38+
}
39+
}
40+
}
41+
42+
// ** Database settings - You can get this info from your web host ** //
43+
/** The name of the database for WordPress */
44+
define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );
45+
46+
/** Database username */
47+
define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
48+
49+
/** Database password */
50+
define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
51+
52+
/**
53+
* Docker image fallback values above are sourced from the official WordPress installation wizard:
54+
* https://github.com/WordPress/WordPress/blob/1356f6537220ffdc32b9dad2a6cdbe2d010b7a88/wp-admin/setup-config.php#L224-L238
55+
* (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!)
56+
*/
57+
58+
/** Database hostname */
59+
define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') );
60+
61+
/** Database charset to use in creating database tables. */
62+
define( 'DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8') );
63+
64+
/** The database collate type. Don't change this if in doubt. */
65+
define( 'DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', '') );
66+
67+
/**#@+
68+
* Authentication unique keys and salts.
69+
*
70+
* Change these to different unique phrases! You can generate these using
71+
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
72+
*
73+
* You can change these at any point in time to invalidate all existing cookies.
74+
* This will force all users to have to log in again.
75+
*
76+
* @since 2.6.0
77+
*/
78+
define( 'AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here') );
79+
define( 'SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here') );
80+
define( 'LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here') );
81+
define( 'NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here') );
82+
define( 'AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here') );
83+
define( 'SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here') );
84+
define( 'LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here') );
85+
define( 'NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here') );
86+
// (See also https://wordpress.stackexchange.com/a/152905/199287)
87+
88+
/**#@-*/
89+
90+
/**
91+
* WordPress database table prefix.
92+
*
93+
* You can have multiple installations in one database if you give each
94+
* a unique prefix. Only numbers, letters, and underscores please!
95+
*/
96+
$table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
97+
98+
/**
99+
* For developers: WordPress debugging mode.
100+
*
101+
* Change this to true to enable the display of notices during development.
102+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
103+
* in their development environments.
104+
*
105+
* For information on other constants that can be used for debugging,
106+
* visit the documentation.
107+
*
108+
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
109+
*/
110+
define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') );
111+
112+
/* Add any custom values between this line and the "stop editing" line. */
113+
114+
// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
115+
// see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
116+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
117+
$_SERVER['HTTPS'] = 'on';
118+
}
119+
// (we include this by default because reverse proxying is extremely common in container environments)
120+
121+
if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
122+
eval($configExtra);
123+
}
124+
125+
/* That's all, stop editing! Happy publishing. */
126+
127+
/** Absolute path to the WordPress directory. */
128+
if ( ! defined( 'ABSPATH' ) ) {
129+
define( 'ABSPATH', __DIR__ . '/' );
130+
}
131+
132+
/** Sets up WordPress vars and included files. */
133+
require_once ABSPATH . 'wp-settings.php';

matrix.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ set -Eeuo pipefail
66
JSON_FILE="versions.json"
77
BASE_DOCKER_TAG="inrage/docker-wordpress"
88

9-
# Fetch the list of available versions (only objects, not wpCliVersion)
10-
versions=$(jq -r 'to_entries | map(select(.value | type == "object")) | map(.key) | .[]' $JSON_FILE)
9+
# Fetch the list of available versions (only objects, exclude experimental and wpCliVersion)
10+
versions=$(jq -r 'to_entries | map(select(.value | type == "object")) | map(.key) | map(select(. != "experimental")) | .[]' $JSON_FILE)
1111

1212
# Initialize the output JSON string
1313
matrix_json="{ \"include\": ["
@@ -52,6 +52,15 @@ for ver in $versions; do
5252
done
5353
done
5454

55+
# Add experimental builds (not managed by apply-templates.sh)
56+
experimental_builds=$(jq -r '.experimental // [] | .[]? | @json' $JSON_FILE)
57+
for build in $experimental_builds; do
58+
context=$(echo "$build" | jq -r '.context')
59+
tag=$(echo "$build" | jq -r '.tag')
60+
name=$(echo "$build" | jq -r '.name')
61+
matrix_json+=" {\"context\": \"${context}\", \"tag\": \"${tag}\", \"name\": \"${name}\"},"
62+
done
63+
5564
# Remove the trailing comma and close the JSON string
5665
matrix_json=${matrix_json%,}
5766
matrix_json+=" ] }"

versions.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
"apache",
2121
"apache-redis"
2222
]
23-
}
23+
},
24+
"experimental": [
25+
{ "context": "experimental/php8.3/apache-event-fpm", "tag": "inrage/docker-wordpress:8.3-event-fpm", "name": "experimental-8.3-event-fpm" }
26+
]
2427
}

0 commit comments

Comments
 (0)