Setting up Sage 9 with Docker

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.ymlSetting 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 -dRunning our containers
For the database, we can use the following information:
DB_NAME: database
DB_USER: dev
DB_PASSWORD: dev
DB_HOST: mysql:3306Database 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 buildTheme 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 startStarting Browsersync session
Now, our assets will be compiled when file changes are made and our site will be visible at localhost:3000.
