cloyne / network

5 stars 5 forks source link

Upgrade Wordpress #81

Closed mitar closed 7 years ago

mitar commented 7 years ago

Upgrade our Wordpress Docker image and then blog image.

ck2qsuZT commented 7 years ago

Why did we choose Wordpress over Drupal?

mitar commented 7 years ago

I used Drupal in the past. I tried Wordpress and found out that it works better for this simple site. Drupal is even harder to manage. Also Wordpress many people (end users) know how to use.

mitar commented 7 years ago

BTW, our Wordpress installation is pretty safe because Docker images are made in a way that they do not allow Wordpress to write to its own code. This means that updating has to be done through updating Docker images and that autoupdating does not work, but it also means that there is much less chance that some vulnerability is exploited.

mitar commented 7 years ago

I had to do this to update from 4.4.2 to 4.6.1. In the docker-wordpress clone (in /srv/repositories/docker-wordpres on server 2):

cd wordpress
git fetch --tags
git checkout 4.6.1
cd ..
git commit -a

If you are committing on the server, you have to make sure git is configured correctly with who is committing. I simply export:

export GIT_AUTHOR_NAME=Mitar ; export GIT_AUTHOR_EMAIL=... ; export GIT_COMMITTER_NAME=Mitar ; export GIT_COMMITTER_EMAIL=...

You can compile image now locally with docker build -t cloyne/wordpress ., or simply git push and then Docker hub will compile it for you.

Next, we have to update the docker-blog which extends from docker-wordpress image. There are two things one should be upgrading, the theme and plugins. Our theme is based on Twenty Thirteen theme. We use git to help us upgrade. In repository:

cd themes/cloyne # go to theme directory
git log . # see changes made in this repository, and find the latest clean update
git checkout 5d522239cc2094712ae0c23d5b841f7abab98ce2 # this is a commit when we upgraded to clean version 1.7
rm -rf * # removing old version
cp -r /srv/repositories/docker-wordpress/wordpress/wp-content/themes/twentythirteen/* . # copying new version of the theme
git commit -m 'Upgraded to Twenty Thirteen theme, version 2.0.' . # you can get the version of theme in style.css
git checkout master # remember hash of the previous branch
git merge ff6ddda # and resolve conflicts
git add style.css # after resolving a conflict, often this is just reusing old Cloyne theme header with new version
git add footer.php
git commit # to finish merge

git push and build image (docker build -t cloyne/blog .).

Plugins one can update through git submodules, but for two which currently have new versions, git mirror is not updated anymore. We have to decide at some point what to do about that. Maybe use some svn2git tool or something ourselves for them.

To run the new image:

docker stop blog
docker rm blog
./run.sh

After opening cloyne.org, a database update was required. Click and done.

Hopefully all plugins work with new Wordpress version.

Events Manager and WP FullCalendar can be upgraded to a new version.