Extending services
Introduction
In most normal use cases, our wp-setup.json
file should be more than enough to configure your WordPress environment for development. However, if you need a more advanced setup, you can easily extend all services from our Docker Compose template.
This is useful for adding other services such as a Redis object cache, a database manager like Adminer, email capture with MailHog, setting custom environment variables, or even extending our Docker images to install additional tools.
Create Your Custom Docker Compose File
To extend the services, you need to load a custom docker compose file, add the following entry to your wp-setup.json
file:
{
"include": "./my-docker-compose-file.yml"
}
Change the ./my-docker-compose-file.yml
file name according to your real file name to load.
Here is an example of a custom Docker Compose file (my-docker-compose-file.yml
):
version: "3.8"
services:
redis:
image: redis:latest
ports:
- "6379:6379"
volumes:
- "${PWD}/redis-data:/data"
adminer:
image: adminer:latest
ports:
- "8080:8080"
mailhog:
image: mailhog/mailhog:latest
ports:
- "1025:1025"
- "8025:8025"
additional-service:
build:
context: ${PWD}/additional-service/
dockerfile: ./Dockerfile
Refer to the Docker Compose documentation for more details on how to extend a composer file.
Default Services in wp-setup
The default Docker Compose configuration provided by WP Setup includes the following services:
wp
: The main WordPress servicewp-test
: A test instance of WordPresswp-cli
: A WP-CLI container for managing WordPresswp-test-cli
: A WP-CLI container for managing the test instancedatabase
: The main database service (MariaDB)database-test
: A test database service (MariaDB)
These services provide a robust foundation for WordPress development and testing, ensuring you have all the necessary components up and running.
See our template file here for a full reference of the environment and volumes used.
Using Relative Paths
When defining paths in your custom Docker Compose file, use ${PWD}
to reference the project root directory. This ensures that the file paths are correctly resolved within the Docker environment.
For example, to mount a volume, use:
volumes:
- "${PWD}/data:/container/path"
This approach ensures that your paths are correctly referenced from the project root since Docker Compose will load relative paths from WP Setup installation, following the main docker compose file directory.