feat: run WordPress projects on native runtime

This commit is contained in:
reaper
2026-08-22 04:11:44 -05:00
parent 6fc33cc8a4
commit 8356a6949a
12 changed files with 1687 additions and 378 deletions
+5 -1
View File
@@ -2,7 +2,11 @@ FROM php:8.5.9-fpm-alpine3.23
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \
nginx=1.30.4-r3 mariadb=11.8.8-r0 mariadb-client=11.8.8-r0 bash file pax-utils \
&& mkdir -p /stage/root /stage/bin /stage/lib
&& mkdir -p /stage/root /stage/bin /stage/lib \
&& curl -fsSLo /tmp/wp-cli.phar https://github.com/wp-cli/wp-cli/releases/download/v2.12.0/wp-cli-2.12.0.phar \
&& echo 'ce34ddd838f7351d6759068d09793f26755463b4a4610a5a5c0a97b68220d85c /tmp/wp-cli.phar' | sha256sum -c -
RUN docker-php-ext-install -j2 mysqli pdo_mysql
COPY stage-runtime.sh /usr/local/bin/stage-runtime
RUN chmod +x /usr/local/bin/stage-runtime && /usr/local/bin/stage-runtime
+22 -1
View File
@@ -63,6 +63,18 @@ EOF
chmod +x "$stage/bin/$name"
done
for name in php php-fpm; do
target=/usr/local/bin/php
[ "$name" = php-fpm ] && target=/usr/local/sbin/php-fpm
cat > "$stage/bin/$name" <<EOF
#!/bin/sh
runtime_root=\$(CDPATH= cd -- "\$(dirname -- "\$0")/.." && pwd)
extension_dir=\$(find "\$runtime_root/root/usr/local/lib/php/extensions" -mindepth 1 -maxdepth 1 -type d -print -quit)
exec "\$runtime_root/bin/aurora-exec" "$target" -d "extension_dir=\$extension_dir" "\$@"
EOF
chmod +x "$stage/bin/$name"
done
# mariadb-install-db is a shell script that calls helpers below --basedir.
# Put the ELF programs behind relocatable wrappers so those calls also use the
# bundled musl loader instead of the host's /lib interpreter.
@@ -91,6 +103,14 @@ exec "$(dirname "$0")/aurora-exec" /usr/libexec/aurora/mariadbd "$@"
EOF
chmod +x "$stage/bin/mariadbd"
cp /tmp/wp-cli.phar "$root/usr/local/bin/wp-cli.phar"
cat > "$stage/bin/wp" <<'EOF'
#!/bin/sh
runtime_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
exec "$runtime_root/bin/php" -d memory_limit=512M "$runtime_root/root/usr/local/bin/wp-cli.phar" "$@"
EOF
chmod +x "$stage/bin/wp"
php_version=$(php -r 'echo PHP_VERSION;')
nginx_version=$(nginx -v 2>&1 | sed 's#nginx version: nginx/##')
mariadb_version=$(mariadbd --version | sed -n 's/.* Ver \([^ -]*\).*/\1/p')
@@ -103,7 +123,8 @@ cat > "$stage/runtime.template.json" <<EOF
"components": [
{ "id": "php", "version": "$php_version", "executable": "bin/php-fpm" },
{ "id": "nginx", "version": "$nginx_version", "executable": "bin/nginx" },
{ "id": "mariadb", "version": "$mariadb_version", "executable": "bin/mariadbd" }
{ "id": "mariadb", "version": "$mariadb_version", "executable": "bin/mariadbd" },
{ "id": "wp-cli", "version": "2.12.0", "executable": "bin/wp" }
]
}
EOF