This post talks about the process I went through to setup my multi-plugin dev env, I need to be able to write code in Gutenberg, WooCommerce Gutenberg Products Blocks, WooCommerce Admin and WooCommerce Core.
Setting up folders
This is just a personal preference, I keep a home folder named work that holds all of the projects I’m working on, it makes switching easier.
Setting up WordPress Develop
Each project you will work has his own setup process, it will mostly be clone, npm install, composer install, npm run build.
This is how you setup WordPress Develop
Note: WordPress Develop has its own docker file, but I’m ignoring that for now.
git clone https://github.com/WordPress/wordpress-develop wordpress
npm run build
This should get you up & running with a trunk version of WordPress, ensuring you get the latest updates.
Setting up Docker
You installed Docker with docker-compose, you have all of your projects set, now it’s time to run them, you will need a docker-compose file, I’m using this file, courtesy to Riad Benguella.
Have that file somewhere, it doesn’t matter where it is since everything is absolute in it, after that, you can run it using:
docker-compose up -d
If you’re running this command for the first time, it will take some time to download the WordPress image, more info into how you can configure it inside that link.
Great, now you should have a WordPress website running at
http://localhost:8889, if it doesn’t work like magic, the most probable thing is that 8889 is already used by another process, check who’s using that port by running:
sudo lsof -i tcp:8889
You can also change your port to something else in the docker-compose file.
Switching WordPress versions
If you feel like using another version of WordPress other than trunk, like the stable version or an older version for testing, you can do this:
Prerequisite (only done once, do it again each release)
git fetch --all --tags --prune
git checkout tags/5.3.0
npm run build
for older versions than 5.3, run
npm run gruntinstead
- cd back to the docker-compose.yml file and run
- WordPress will ask for a DB update, confirm that.
Congrash, you’re using said version of WordPress.