Loading Dockerfile +3 −2 Original line number Diff line number Diff line Loading @@ -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 Loading data/composer.json 0 → 100644 +16 −0 Original line number Diff line number Diff line { "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" ] } } data/wp-config.php +7 −0 Original line number Diff line number Diff line Loading @@ -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('vendor/autoload.php') ) require_once 'vendor/autoload.php'; plugins/s3-uploads-config.php 0 → 100644 +20 −0 Original line number Diff line number Diff line <?php /** * Plugin Name: S3-Uploads Configuration * Plugin URI: https://code.kodo.org.uk/singing-chimes.co.uk/wordpress/tree/master/plugins * Description: Filters S3-Uploads parameters to configure the plugin * Licence: MPL-2.0 * Licence URI: https://www.mozilla.org/en-US/MPL/2.0/ * Author: Dominik Sekotill * Author URI: https://code.kodo.org.uk/dom */ add_filter( 's3_uploads_s3_client_params', function ( $params ) { $params['endpoint'] = S3_UPLOADS_BUCKET_URL; $params['bucket_endpoint'] = true; $params['disable_host_prefix_injection'] = true; $params['use_path_style_endpoint'] = true; $params['debug'] = WP_DEBUG && WP_DEBUG_DISPLAY; $params['region'] = ''; return $params; } ); scripts/entrypoint.sh +35 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ declare -a STATIC_PATTERNS=( "LICEN[CS]E" "README" "readme.html" "composer.*" ) declare -a PHP_DIRECTIVES=( ${PHP_DIRECTIVES-} Loading Loading @@ -94,6 +95,34 @@ setup_database() { wp rewrite structure /posts/%postname% } setup_s3() { # https://github.com/humanmade/S3-Uploads declare -a configs=( "${!S3_ENDPOINT_@}" ) [[ ${#configs[*]} -gt 0 ]] || return 0 [[ -v S3_UPLOADS_ENDPOINT ]] && [[ -v S3_ENDPOINT_KEY ]] && [[ -v S3_ENDPOINT_SECRET ]] || return 0 wp plugin activate s3-uploads [[ -v S3_UPLOADS_USE_LOCAL ]] && wp config set S3_UPLOADS_USE_LOCAL true --raw wp config set S3_UPLOADS_BUCKET_URL "${S3_UPLOADS_ENDPOINT}" wp config set S3_UPLOADS_KEY ${S3_ENDPOINT_KEY} wp config set S3_UPLOADS_SECRET ${S3_ENDPOINT_SECRET} --quiet # Plugin requires something here, it's not used wp config set S3_UPLOADS_REGION '' # Due to what appears to be a bug in the plugin, this MUST be a non-empty # string; mostly it just affects the log output wp config set S3_UPLOADS_BUCKET "CONFIGURED-BUCKET" } setup_components() { setup_database Loading @@ -104,6 +133,7 @@ setup_components() { wp language core update wp language plugin update --all wp language theme update --all composer update --prefer-dist # Ensure at least one theme is installed [[ ${#THEMES[*]} -eq 0 ]] && THEMES+=( ${DEFAULT_THEME} ) Loading @@ -119,6 +149,8 @@ setup_components() { [[ $(wp theme list --status=active --format=count) -eq 0 ]] && wp theme activate $(wp theme list --field=name | head -n1) setup_s3 return 0 } Loading @@ -140,8 +172,9 @@ collect_static() --delete-delay \ --exclude-from=- \ --exclude='*.php' \ --exclude=static/ \ --exclude=media/ \ --exclude=/static/ \ --exclude=/media/ \ --exclude=/vendor/ \ --force \ --info="${flags[*]}" \ --times \ Loading Loading
Dockerfile +3 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
data/composer.json 0 → 100644 +16 −0 Original line number Diff line number Diff line { "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" ] } }
data/wp-config.php +7 −0 Original line number Diff line number Diff line Loading @@ -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('vendor/autoload.php') ) require_once 'vendor/autoload.php';
plugins/s3-uploads-config.php 0 → 100644 +20 −0 Original line number Diff line number Diff line <?php /** * Plugin Name: S3-Uploads Configuration * Plugin URI: https://code.kodo.org.uk/singing-chimes.co.uk/wordpress/tree/master/plugins * Description: Filters S3-Uploads parameters to configure the plugin * Licence: MPL-2.0 * Licence URI: https://www.mozilla.org/en-US/MPL/2.0/ * Author: Dominik Sekotill * Author URI: https://code.kodo.org.uk/dom */ add_filter( 's3_uploads_s3_client_params', function ( $params ) { $params['endpoint'] = S3_UPLOADS_BUCKET_URL; $params['bucket_endpoint'] = true; $params['disable_host_prefix_injection'] = true; $params['use_path_style_endpoint'] = true; $params['debug'] = WP_DEBUG && WP_DEBUG_DISPLAY; $params['region'] = ''; return $params; } );
scripts/entrypoint.sh +35 −2 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ declare -a STATIC_PATTERNS=( "LICEN[CS]E" "README" "readme.html" "composer.*" ) declare -a PHP_DIRECTIVES=( ${PHP_DIRECTIVES-} Loading Loading @@ -94,6 +95,34 @@ setup_database() { wp rewrite structure /posts/%postname% } setup_s3() { # https://github.com/humanmade/S3-Uploads declare -a configs=( "${!S3_ENDPOINT_@}" ) [[ ${#configs[*]} -gt 0 ]] || return 0 [[ -v S3_UPLOADS_ENDPOINT ]] && [[ -v S3_ENDPOINT_KEY ]] && [[ -v S3_ENDPOINT_SECRET ]] || return 0 wp plugin activate s3-uploads [[ -v S3_UPLOADS_USE_LOCAL ]] && wp config set S3_UPLOADS_USE_LOCAL true --raw wp config set S3_UPLOADS_BUCKET_URL "${S3_UPLOADS_ENDPOINT}" wp config set S3_UPLOADS_KEY ${S3_ENDPOINT_KEY} wp config set S3_UPLOADS_SECRET ${S3_ENDPOINT_SECRET} --quiet # Plugin requires something here, it's not used wp config set S3_UPLOADS_REGION '' # Due to what appears to be a bug in the plugin, this MUST be a non-empty # string; mostly it just affects the log output wp config set S3_UPLOADS_BUCKET "CONFIGURED-BUCKET" } setup_components() { setup_database Loading @@ -104,6 +133,7 @@ setup_components() { wp language core update wp language plugin update --all wp language theme update --all composer update --prefer-dist # Ensure at least one theme is installed [[ ${#THEMES[*]} -eq 0 ]] && THEMES+=( ${DEFAULT_THEME} ) Loading @@ -119,6 +149,8 @@ setup_components() { [[ $(wp theme list --status=active --format=count) -eq 0 ]] && wp theme activate $(wp theme list --field=name | head -n1) setup_s3 return 0 } Loading @@ -140,8 +172,9 @@ collect_static() --delete-delay \ --exclude-from=- \ --exclude='*.php' \ --exclude=static/ \ --exclude=media/ \ --exclude=/static/ \ --exclude=/media/ \ --exclude=/vendor/ \ --force \ --info="${flags[*]}" \ --times \ Loading