Loading entrypoint.sh +37 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ declare -a STATIC_PATTERNS=( "LICEN[CS]E" "README" "readme.html" "composer.*" ) declare -a PHP_DIRECTIVES=( ${PHP_DIRECTIVES-} Loading Loading @@ -82,6 +83,37 @@ 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 ]] && [[ S3_ENDPOINT_KEY ]] && [[ S3_ENDPOINT_SECRET ]] || return composer require humanmade/s3-uploads # S3-Uploads looks for vendor/ in the wrong place ln -sf /app/vendor wp-content/plugins/s3-uploads/ 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 @@ -93,6 +125,8 @@ setup_components() { wp language plugin update --all wp language theme update --all setup_s3 # Ensure at least one theme is installed [[ ${#THEMES[*]} -eq 0 ]] && THEMES+=( ${DEFAULT_THEME} ) Loading Loading @@ -121,8 +155,9 @@ collect_static() --delete-delay \ --exclude-from=- \ --exclude='*.php' \ --exclude=static/ \ --exclude=media/ \ --exclude=/static/ \ --exclude=/media/ \ --exclude=/vendor/ \ --force \ --info="${flags[*]}" \ --times \ Loading scripts/install-wp.sh +23 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,13 @@ set -eux WP_PASSWORD_HASH=https://raw.githubusercontent.com/Ayesh/WordPress-Password-Hash/1.5.1 COMPOSER_INSTALLER_URL=https://getcomposer.org/installer WP_CLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # Install Composer curl -sSL ${COMPOSER_INSTALLER_URL} | php -- --install-dir=/usr/local/lib --filename=composer.phar ln -s ../lib/composer.phar /usr/local/bin/composer # Install WP-CLI curl -sSL ${WP_CLI_URL} \ Loading @@ -20,3 +27,19 @@ 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 S3-Uploads customisations cat >wp-content/mu-plugins/s3-endpoint.php \ <<-'END_PHP' <?php // Filter S3 Uploads params. 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; $params['region'] = ''; return $params; } ); END_PHP Loading
entrypoint.sh +37 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ declare -a STATIC_PATTERNS=( "LICEN[CS]E" "README" "readme.html" "composer.*" ) declare -a PHP_DIRECTIVES=( ${PHP_DIRECTIVES-} Loading Loading @@ -82,6 +83,37 @@ 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 ]] && [[ S3_ENDPOINT_KEY ]] && [[ S3_ENDPOINT_SECRET ]] || return composer require humanmade/s3-uploads # S3-Uploads looks for vendor/ in the wrong place ln -sf /app/vendor wp-content/plugins/s3-uploads/ 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 @@ -93,6 +125,8 @@ setup_components() { wp language plugin update --all wp language theme update --all setup_s3 # Ensure at least one theme is installed [[ ${#THEMES[*]} -eq 0 ]] && THEMES+=( ${DEFAULT_THEME} ) Loading Loading @@ -121,8 +155,9 @@ collect_static() --delete-delay \ --exclude-from=- \ --exclude='*.php' \ --exclude=static/ \ --exclude=media/ \ --exclude=/static/ \ --exclude=/media/ \ --exclude=/vendor/ \ --force \ --info="${flags[*]}" \ --times \ Loading
scripts/install-wp.sh +23 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,13 @@ set -eux WP_PASSWORD_HASH=https://raw.githubusercontent.com/Ayesh/WordPress-Password-Hash/1.5.1 COMPOSER_INSTALLER_URL=https://getcomposer.org/installer WP_CLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar # Install Composer curl -sSL ${COMPOSER_INSTALLER_URL} | php -- --install-dir=/usr/local/lib --filename=composer.phar ln -s ../lib/composer.phar /usr/local/bin/composer # Install WP-CLI curl -sSL ${WP_CLI_URL} \ Loading @@ -20,3 +27,19 @@ 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 S3-Uploads customisations cat >wp-content/mu-plugins/s3-endpoint.php \ <<-'END_PHP' <?php // Filter S3 Uploads params. 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; $params['region'] = ''; return $params; } ); END_PHP