diff --git a/Dockerfile b/Dockerfile index 61f1816ad7c808be6c5211afb5ae033381d211e9..8ee65ebdb2ae4f0cedc830a9e842148529abab39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,13 +20,14 @@ ARG wp_version=latest WORKDIR /app ENV WORDPRESS_ROOT=/app -COPY scripts/wp.sh /usr/local/bin/wp COPY --from=compile /usr/local/etc/php /usr/local/etc/php COPY --from=compile /usr/local/lib/php /usr/local/lib/php +COPY scripts/wp.sh /usr/local/bin/wp +COPY data/composer.json /app/composer.json RUN --mount=type=bind,source=scripts/install-wp.sh,target=/stage \ /stage ${wp_version} -COPY plugins/probe.php wp-content/mu-plugins/ +COPY plugins/* wp-content/mu-plugins/ COPY data/fpm.conf /usr/local/etc/php-fpm.d/image.conf COPY data/opcache.ini /usr/local/etc/php/conf.d/opcache-recommended.ini COPY data/wp-config.php /usr/share/wordpress/wp-config.php diff --git a/data/composer.json b/data/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..c028f78b051f0f31074739ee76689ab6e3514fbd --- /dev/null +++ b/data/composer.json @@ -0,0 +1,21 @@ +{ + "type": "project", + "license": "MPL-2.0", + "repositories": [ + { + "type": "gitlab", + "url": "https://code.kodo.org.uk/singing-chimes.co.uk/s3-uploads" + } + ], + "require": { + "humanmade/s3-uploads": "dev-develop" + }, + "config": { + "gitlab-domains": [ "code.kodo.org.uk" ] + }, + "extra": { + "installer-paths": { + "wp-content/mu-plugins/{$name}/": [ "type:wordpress-plugin" ] + } + } +} diff --git a/data/wp-config.php b/data/wp-config.php index 78063c294ec38bbcb32a6a03434f031e5a70a670..b05132f7b3d42c3aec4b0e817e5707a4a5c1ad41 100644 --- a/data/wp-config.php +++ b/data/wp-config.php @@ -22,3 +22,10 @@ define('DISABLE_WP_CRON', true); * installation. **/ define('UPLOADS', 'media'); + +/** + * Run the Composer autoloader, if available + * Assume the CWD is always /app and vendor is always in it. + **/ +if ( is_file(ABSPATH . 'vendor/autoload.php') ) + require_once ABSPATH . 'vendor/autoload.php'; diff --git a/plugins/media-url.php b/plugins/media-url.php index d1b1171bb6f986110dd50ee51323ba4faecbc1fb..955cc97efdfeb5932785cb6b042e549ef08c74b3 100644 --- a/plugins/media-url.php +++ b/plugins/media-url.php @@ -30,7 +30,7 @@ function unparse_url( array $parts ) { (isset($parts['scheme']) ? "{$parts['scheme']}://" : '') . (isset($parts['user']) ? $parts['user'] : '') . (isset($parts['pass']) ? ":{$parts['pass']}" : '') . - (isset($parts['user'] || isset($parts['pass'])) ? '@' : '') . + (isset($parts['user']) || isset($parts['pass']) ? '@' : '') . (isset($parts['host']) ? $parts['host'] : '') . (isset($parts['port']) ? ":{$parts['port']}" : '') . (isset($parts['path']) ? $parts['path'] : '') . diff --git a/plugins/s3-uploads.php b/plugins/s3-uploads.php new file mode 100644 index 0000000000000000000000000000000000000000..727db18f1550cb45e83a06a128c11ec273ab1109 --- /dev/null +++ b/plugins/s3-uploads.php @@ -0,0 +1,26 @@ +/usr/local/lib/wp-cli.phar @@ -21,3 +27,7 @@ mkdir -p wp-content/mu-plugins # Install non-optional plugins curl ${WP_PASSWORD_HASH}/wp-php-password-hash.php \ >wp-content/mu-plugins/password-hash.php + +# Install composer managed dependencies +export COMPOSER_ALLOW_SUPERUSER=1 +composer install --prefer-dist