A quick way to start a project with WordPress using Docker.
The development environment is managed by Docker using Docker Compose. The docker-compose.yml`_ has the definiton of the tools used to run the project. You must have installed the Docker program. If you haven't, you can get it here.
It is recommended maintain the images always updated. Execute the pull and build commands to get the updated images.
$ docker-compose pull && docker-compose build
To install the application the database directory must be empty. Ensure that the database directory doesn't exist.
$ sudo rm -rf database
To create the database, it only need up the database container.
$ docker-compose up db
Keep this process running. To test if the database was created, open a new terminal tab and execute the below command. The database service can take a while to start. So this command will fail until the service be up.
$ docker-compose exec db mysql -u project -pproject project
If after some seconds, the database could not be connected. Restart the installation process.
Download PHP packages, including the WordPress.
$ docker-compose run --rm composer install
Download Node packages
$ docker-compose run --rm node npm install
Download Bower packages
$ docker-compose run --rm node bower install
Build the theme
$ docker-compose run --rm node grunt
After source app/profile, the theme language POT file is generated with the command
$ i18n
Install the WordPress
$ docker-compose run --rm php bin/install
The website will be served in http://localhost.
Up the server and the watch task.
$ docker-compose up server watch
$ docker-compose -f docker-compose.yml -f docker-compose.mac.yml up server watch
The production server use the PHP 5.6. To up locally a server with this version is necessary uninstall dev PHP packages because Deployer doesn't work in PHP version minor than 7. The images must be built to change the PHP version.
$ docker-compose -f docker-compose.yml -f docker-compose.php56.yml build --pull
$ composer install --no-dev
$ docker-compose -f docker-compose.yml -f docker-compose.php56.yml up server watch
$ docker-compose -f docker-compose.yml -f docker-compose.php56.yml -f docker-compose.mac.yml up server watch
$ composer install
$ docker-compose build --pull
The project is configured to validate the quality of the PHP code. It is used the WordPress Coding Standards as base to code validation.
The validation isn't done by the watch service. Because is a PHP execution and for now isn't wrappered by the node image. Execute this command to run the code sniffer:
$ docker-compose run --rm php phpcs
And to fix some warnings using the PHP Code Beautifier and Fixer, execute:
$ docker-compose run --rm php phpcbf
The project is configured to validate the quality of the Stylus and Javascript code
$ docker-compose run --rm node grunt lint
A database dump can be found on branch data
, you can import with the following commands:
$ git checkout origin/data app/initdb
$ wp db reset --yes
$ zcat app/initdb/initdb.sql.gz | wp db import -