Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh
COPY wp-config.php /usr/src/wordpress
RUN chown nobody.nobody /usr/src/wordpress/wp-config.php && chmod 640 /usr/src/wordpress/wp-config.php

# Append WP secrets
COPY wp-secrets.php /usr/src/wordpress
RUN chown nobody.nobody /usr/src/wordpress/wp-secrets.php && chmod 640 /usr/src/wordpress/wp-secrets.php
# Link wp-secrets to location on wp-content
RUN ln -s /var/www/wp-content/wp-secrets.php /usr/src/wordpress/wp-secrets.php

# Entrypoint to copy wp-content
COPY entrypoint.sh /entrypoint.sh
Expand Down
20 changes: 17 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ if [ ! "$(ls -A "/var/www/wp-content" 2>/dev/null)" ]; then
# Copy wp-content from Wordpress src to volume
cp -r /usr/src/wordpress/wp-content /var/www/
chown -R nobody.nobody /var/www

# Generate secrets
curl -f https://api.wordpress.org/secret-key/1.1/salt/ >> /usr/src/wordpress/wp-secrets.php
fi
# Check if wp-secrets.php exists
if ! [ -f "/var/www/wp-content/wp-secrets.php" ]; then
# Check that secrets environment variables are not set
if [ ! $AUTH_KEY ] \
&& [ ! $SECURE_AUTH_KEY ] \
&& [ ! $LOGGED_IN_KEY ] \
&& [ ! $NONCE_KEY ] \
&& [ ! $AUTH_SALT ] \
&& [ ! $SECURE_AUTH_SALT ] \
&& [ ! $LOGGED_IN_SALT ] \
&& [ ! $NONCE_SALT ]; then
echo "Generating wp-secrets.php"
# Generate secrets
echo '<?php' > /var/www/wp-content/wp-secrets.php
curl -f https://api.wordpress.org/secret-key/1.1/salt/ >> /var/www/wp-content/wp-secrets.php
fi
fi
exec "$@"
2 changes: 0 additions & 2 deletions wp-secrets.php

This file was deleted.