Setting up Sage 9 with Docker

Image from Pexels

Sage is a WordPress starter theme developed by Roots. Let’s see how we can quickly set it up with Docker.


To achieve our goal, we are going to use the PHP Docker Boilerplate from WebDevOps. We can clone the repository by simply use:

git clone https://github.com/webdevops/php-docker-boilerplate.git wordpress-project
cd wordpress-project
cp docker-compose.development.yml docker-compose.yml

Setting up the environment

If we want to use phpMyAdmin, we can remove comments at the following lines at the end of the docker-compose.yml file:

phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mysql
environment:
- PMA_HOSTS=mysql
- VIRTUAL_HOST=pma.boilerplate.docker
- VIRTUAL_PORT=80
volumes:
- /sessions
ports:
- "8001:80"

docker-compose.yml file

Now, we can simply do the following command:

docker-compose up -d

Running our containers

For the database, we can use the following information:

DB_NAME: database
DB_USER: dev
DB_PASSWORD: dev
DB_HOST: mysql:3306

Database information

Now, in our directory wp-content/themes, we can do the following thing:

composer create-project roots/sage sage dev-master
cd sage
yarn
yarn run build

Theme installation

We just have to do one last thing: in the resources/assets/config.json file, we have to change the following lines:

...
"publicPath": "/wp-content/themes/sage",
"devUrl": "http://localhost:8000",
...

resources/assets/config.json file

Now, if the theme is activated in wp-admin, we just have to run the following command:

yarn run start

Starting Browsersync session

Now, our assets will be compiled when file changes are made and our site will be visible at localhost:3000.

Mátyás Lancelot Bors

Written by

WebDeveloper / Writer / Musician / https://www.mlbors.com / https://medium.com/@mlbors

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade