forked from coop-cloud/wordpress
- compose.matrix.yml: add trailing newline
- compose.ftp-222*.yml: fix YAML indentation (8->6 spaces)
- entrypoint.sh.tmpl: fix SC2198 ([ -n "$@" ] -> [ $# -gt 0 ])
- All .tmpl files: migrate from {{ env }} to {{ getenv }} for gomplate v5 compat
- uploads.ini.tmpl: add {{- / -}} whitespace trimming, fix double-space typo
- tests/run.sh: only run ShellCheck on *.sh.tmpl files
- tests/test_shell.sh: gracefully skip if shellcheck not installed
- tests/test_templates.sh: remove dead render() function,
gracefully skip if gomplate not found, use set -a/. for env sourcing
- tests/test_compose_config.sh: validate override files combined
with compose.yml, skip partial snippets needing more context
- README.md: add test instructions with brew install
66 lines
2.2 KiB
Bash
66 lines
2.2 KiB
Bash
#!/bin/bash
|
|
|
|
{{ if (getenv "PHP_EXTENSIONS") }}
|
|
docker-php-ext-install {{ getenv "PHP_EXTENSIONS" }}
|
|
{{ end }}
|
|
|
|
curl -z /usr/local/bin/wp -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
|
chmod +x /usr/local/bin/wp
|
|
|
|
{{ if eq (getenv "ENABLE_COMPOSER") "1" }}
|
|
mkdir -p /var/www/.composer
|
|
chown www-data:www-data /var/www/.composer /var/www/html/composer
|
|
|
|
curl https://getcomposer.org/installer -o /tmp/composer-setup.php
|
|
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
|
|
php /tmp/composer-setup.php
|
|
rm /tmp/composer-setup.php
|
|
|
|
mv /var/www/html/composer.phar /usr/local/bin/composer
|
|
{{ end }}
|
|
|
|
{{ if eq (getenv "CORS_ALLOW_ALL") "1" }}
|
|
a2enmod headers
|
|
sed -ri -e 's/^([ \t]*)(<\/VirtualHost>)/\1\tHeader set Access-Control-Allow-Origin "*"\n\1\2/g' /etc/apache2/sites-available/*.conf
|
|
{{ end }}
|
|
|
|
{{ if eq (getenv "MULTISITE") "enable" }}
|
|
export WORDPRESS_CONFIG_EXTRA="$WORDPRESS_CONFIG_EXTRA
|
|
define('WP_CACHE', false);
|
|
define('WP_ALLOW_MULTISITE', true );"
|
|
{{ end }}
|
|
|
|
{{ if or (eq (getenv "MULTISITE") "subdomain") (eq (getenv "MULTISITE") "subfolder") }}
|
|
export WORDPRESS_CONFIG_EXTRA="$WORDPRESS_CONFIG_EXTRA
|
|
define('MULTISITE', true);
|
|
define('SUBDOMAIN_INSTALL', true);
|
|
define('DOMAIN_CURRENT_SITE', '${DOMAIN}');
|
|
define('PATH_CURRENT_SITE', '/');
|
|
define('SITE_ID_CURRENT_SITE', 1);
|
|
define('BLOG_ID_CURRENT_SITE', 1);
|
|
define('FORCE_SSL_ADMIN', true );
|
|
define('COOKIE_DOMAIN', \$_SERVER['HTTP_HOST']);"
|
|
{{ end }}
|
|
|
|
|
|
UPLOADS_HTACCESS=/var/www/html/wp-content/uploads/.htaccess
|
|
if [ ! -f "$UPLOADS_HTACCESS" ]; then
|
|
mkdir -p /var/www/html/wp-content/uploads
|
|
cat > "$UPLOADS_HTACCESS" <<'EOF'
|
|
# Prevent PHP execution in uploads directory
|
|
<FilesMatch "\.(?i:php|phtml|phar)$">
|
|
Require all denied
|
|
</FilesMatch>
|
|
EOF
|
|
fi
|
|
|
|
chown -R --from=root:root www-data:www-data /var/www/html/wp-content/
|
|
|
|
if [ $# -gt 0 ]; then
|
|
"$@"
|
|
fi
|
|
|
|
# Upstream ENTRYPOINT
|
|
# https://github.com/docker-library/wordpress/blob/master/php7.4/apache/Dockerfile#L120
|
|
/usr/local/bin/docker-entrypoint.sh apache2-foreground
|