Skip to content

Commit

Permalink
fix(wordpress): fix ssl always being forced and plugins not installing (
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine authored Sep 19, 2024
1 parent 90a89c3 commit 3125f1c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 82 deletions.
69 changes: 0 additions & 69 deletions images/wordpress/.env.template

This file was deleted.

9 changes: 6 additions & 3 deletions images/wordpress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,19 @@ COPY ./config/wordpress /tmp/wordpress
# Copy nginx config
COPY ./etc/nginx/http.d/* /etc/nginx/http.d/

ENV PHP_VERSION=${PHP_VERSION}
ENV WP_VERSION=${WP_VERSION}

ENV ROOT_DIR=${ROOT_DIR}

###
# Core
###
ENV BASE_URL=localhost:8130
ENV FULL_URL=https://${BASE_URL}
ENV ROOT_DIR=/var/www/html
ENV ROOT_DIR=${ROOT_DIR}
ENV WITH_NGINX=0

ENV TMP_PLUGINS_DIR="/tmp/plugins"
ENV WP_PLUGINS_DIR="${ROOT_DIR}/wp-content/plugins"

###
# Database
Expand Down
8 changes: 5 additions & 3 deletions images/wordpress/config/wordpress/wp-cli.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ config create:
@ini_set('display_errors', ${DISPLAY_ERRORS:-0});
# SSL
define('FORCE_SSL_ADMIN', true);
$$_SERVER['HTTPS'] = 'on';
# Force SSL if the URL starts with https://
if (strpos('${WP_URL_REPLACE}', 'https://') === 0) {
define('FORCE_SSL_ADMIN', true);
$$_SERVER['HTTPS'] = 'on';
}
# Other
$$_SERVER['document_root'] = dirname(__FILE__);
Expand Down
27 changes: 23 additions & 4 deletions images/wordpress/scripts/_install-plugins.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
install-plugins() {
h1 "Linking, installing and activating plugins..."

PLUGINS_FOUND=$(find "$TMP_PLUGINS_DIR" -type d -mindepth 1 -maxdepth 1)

link-paths "$TMP_PLUGINS_DIR" "$WP_PLUGINS_DIR"

if [ -n "$WP_SKIP_PLUGINS" ]; then
h2 "Skipping plugin installation because WP_SKIP_PLUGINS is set."
return
fi

for path in "$TMP_PLUGINS_DIR"/*/; do
plugin=$(basename "$path")
if [ -z "$PLUGINS_FOUND" ]; then
h2 "No local plugins to install."
else
h2 "Installing local plugins..."
for path in $PLUGINS_FOUND; do
plugin=$(basename "$path")

wp-activate plugin "$plugin"
done
fi

PLUGINS_LIST=$(echo "$WP_PLUGINS" | tr ',' '\n')

if [ -z "$PLUGINS_LIST" ]; then
h2 "No remote plugins to install."
else
h2 "Downloading and installing remote plugins..."

wp-activate plugin "$plugin"
done
for plugin in $PLUGINS_LIST; do
wp-activate plugin "$plugin"
done
fi

h2 "Finished installing and activating plugins."
}
3 changes: 0 additions & 3 deletions images/wordpress/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

declare -i term_width=70

export TMP_PLUGINS_DIR="/tmp/plugins"
export WP_PLUGINS_DIR="$ROOT_DIR/wp-content/plugins"

for script in /tmp/scripts/_*; do source $script; done

# Start php fpm in the background in advance.
Expand Down

0 comments on commit 3125f1c

Please sign in to comment.