The adventures of Wordpress containerization and theme development with Docker.
- Docker 18.09.0
- Docker Compose 1.23.2
If you have node.js (and thus, probably npm) installed, that'd be super nice. We're using npm scripts to build, start, stop and remove containers. In the future, when this whole containerization process is fleshed out properly and the developer experience is smooth, you'll need to have node.js installed either way for theme development.
First, create .env
file to the root of the project directory and use the .env.example
as a reference. For example;
DB_USER=digitalents_wp
DB_PASSWORD=supersecret
DB_NAME=digitalents_wp
Depending on your operating system, the process of starting up the containers should be either straightforward or slightly annoying. MacOS setup is literally one command away from being ready for development purposes, while Linux requires you to chown
ing some directories. Don't even ask about Windows, I have literally no clue if it'll work there.
npm run build:up
builds images and starts the containers specified indocker-compose.yaml
file.- Browse to http://localhost:8080 and finish the WP configuration using your preferred username and password.
npm run build:up
builds images and starts the containers specified indocker-compose.yaml
file.sudo chown -R <uid>:www-data theme/ gutenberg-blocks/
gives your docker host user's permission to write to these specific directories.- Browse to http://localhost:8080 and finish the WP configuration using your preferred username and password.
If you need to restart the containers, npm run build:down
does that for you. You can also check out the build.sh
shell script on the root directory to see more options, such as stopping and removing both the containers and their respective volumes... Or just do it yourself using docker-compose
.