Skip to content
Closed
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
8 changes: 8 additions & 0 deletions docker-entrypoint.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,6 +43,14 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
EOF
chown www-data:www-data .htaccess
fi
else
CONTAINER_WORDPRESS_VERSION=$(php -r "include('/usr/src/wordpress/wp-includes/version.php'); echo \$wp_version;")
INSTALLED_WORDPRESS_VERSION=$(php -r "include('wp-includes/version.php'); echo \$wp_version;")
if ! [ "$CONTAINER_WORDPRESS_VERSION" == "$INSTALLED_WORDPRESS_VERSION" ]; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to add this, it really needs to be a full version comparison and then only upgrade when container version is newer. Otherwise, if a user has WordPress set to auto-upgrade itself (which I believe is the default), then when the container restarts, they will get auto downgraded.

I wonder if this should also be behind a env flag of some sort so that users don't get unexpected upgrades when they start a new container.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the initial files installed by the container are owned by root, so wordpress cannot autoupdate itself with the current entrypoint script as of now.

@jonknappjonknappSep 26, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regards to putting it behind a flag, wouldn't this issue only occur for users that are pointing to latest instead of a set version? Otherwise, the container's version of wordpress would not change and would not trigger an upgrade of files.

(well, it would only occur for latest as long as wordpress cannot auto-update itself)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the files are correctly owned by www-data, since the tar cf - --one-file-system -C /usr/src/wordpress . | tar xf - preserves the user id from /usr/src/wordpress.

$ docker exec -it word bashroot@79cc11d29c37:/var/www/html# ls -ltotal 188-rw-r--r-- 1 www-data www-data 418 Sep 25 2013 index.php-rw-r--r-- 1 www-data www-data 19935 Mar 5 2016 license.txt-rw-r--r-- 1 www-data www-data 7344 Aug 16 20:39 readme.html-rw-r--r-- 1 www-data www-data 5456 May 24 21:02 wp-activate.phpdrwxr-xr-x 9 www-data www-data 4096 Sep 20 20:34 wp-admin-rw-r--r-- 1 www-data www-data 364 Dec 19 2015 wp-blog-header.php-rw-r--r-- 1 www-data www-data 1477 May 23 16:44 wp-comments-post.php-rw-r--r-- 1 www-data www-data 2853 Sep 26 18:31 wp-config-sample.php-rw-r--r-- 1 www-data www-data 3235 Sep 26 18:31 wp-config.phpdrwxr-xr-x 4 www-data www-data 4096 Sep 20 20:34 wp-content-rw-r--r-- 1 www-data www-data 3286 May 24 2015 wp-cron.phpdrwxr-xr-x 17 www-data www-data 12288 Sep 20 20:34 wp-includes-rw-r--r-- 1 www-data www-data 2382 May 23 16:44 wp-links-opml.php-rw-r--r-- 1 www-data www-data 3353 Apr 14 17:53 wp-load.php-rw-r--r-- 1 www-data www-data 34057 Jun 14 21:51 wp-login.php-rw-r--r-- 1 www-data www-data 7786 Jul 13 12:37 wp-mail.php-rw-r--r-- 1 www-data www-data 13920 Aug 13 16:02 wp-settings.php-rw-r--r-- 1 www-data www-data 29890 May 24 20:44 wp-signup.php-rw-r--r-- 1 www-data www-data 4035 Nov 30 2014 wp-trackback.php-rw-r--r-- 1 www-data www-data 3064 Jul 6 12:40 xmlrpc.php

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have mistaken a WP upgrade issue with the /var/www/html volume being recreated with docker-compose until I specifically mapped that to a named volume.

echo >&2 "Upgrading Wordpress from $INSTALLED_WORDPRESS_VERSION to $CONTAINER_WORDPRESS_VERSION"
tar cf - --one-file-system -C /usr/src/wordpress --exclude=wp-content . | tar xf -
echo >&2 "Complete! WordPress has been successfully upgraded to $(pwd)"
fi
fi

# TODO handle WordPress upgrades magically in the same way, but only if wp-includes/version.php's $wp_version is less than /usr/src/wordpress/wp-includes/version.php's $wp_version
Expand Down