|
1 | 1 | # Docker WordPress Environment |
2 | 2 |
|
3 | | -This is a basic **Docker WordPress Environment** focused on the development of **plugins and themes**, supports [WP-CLI](https://wp-cli.org/) and [phpMyAdmin](https://www.phpmyadmin.net/). |
| 3 | +This is a basic **Docker WordPress Environment** focused on the development of **plugins and themes**, supports [WP-CLI](https://wp-cli.org/), [phpMyAdmin](https://www.phpmyadmin.net/) and [Xdebug](https://xdebug.org/). |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Introduction](#docker-wordpress-environment) |
| 8 | + - [Services](#services) |
| 9 | +- [Requirements](#requirements) |
| 10 | +- [Usage](#usage) |
| 11 | + - [Variables](#variables) |
| 12 | +- [Contributing and Support](#contributing-and-support) |
4 | 13 |
|
5 | 14 | --- |
6 | 15 |
|
7 | 16 | > **Disclaimer:** This project is meant to be used for development purposes only. It's **not** meant to be used in production. |
8 | 17 |
|
9 | | -> It's work in progress. Feel free to contribute if you have anything useful to add. |
10 | | -
|
11 | 18 | --- |
12 | 19 |
|
| 20 | +### Services |
| 21 | + |
| 22 | +Docker services used on [docker-compose. yml](https://github.com/sarahcssiqueira/docker-wordpress/blob/master/docker/docker-compose.yml): |
| 23 | + |
| 24 | +- **db** |
| 25 | + |
| 26 | +The MYSQL official image. |
| 27 | + |
| 28 | +- **phpMyAdmin** |
| 29 | + |
| 30 | +Intended to handle the administration of MySQL, in this case through port 80, on browser [localhost:8080/](localhost:8080/). |
| 31 | + |
| 32 | +- **WordPress** |
| 33 | + |
| 34 | +Uses the official WordPress latest docker image. |
| 35 | + |
| 36 | +- **WP-CLI** |
| 37 | + |
| 38 | +The **wpcli container** was added to only run one-off commands. Don’t need it to run as a service, only as a cli tool, for that run: |
| 39 | + |
| 40 | +`docker-compose run --rm wpcli command` |
| 41 | + |
| 42 | +## Requirements |
| 43 | + |
| 44 | +- [Docker](https://www.docker.com/) hub installed. |
| 45 | + |
13 | 46 | ## Usage |
14 | 47 |
|
15 | | -Clone this repository, then cd the **docker folder** and run `docker-compose up -d` to start your project. |
| 48 | +Clone this repository `git clone https://github.com/sarahcssiqueira/docker-wordpress` |
| 49 | +then cd the **docker folder** `cd docker` and set up your chosen variables on the .env file. |
| 50 | + |
| 51 | +### Variables |
| 52 | + |
| 53 | +The variables used for WordPress installation are the following ones, you can use the same or change them, it's up to you. |
| 54 | + |
| 55 | +``` |
| 56 | +MYSQL_DATABASE_NAME=exampledatabase |
| 57 | +MYSQL_USER=exampleuser |
| 58 | +MYSQL_PASSWORD=examplepass |
| 59 | +WORDPRESS_PORT=8000 |
| 60 | +``` |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +> WARNING: DO NOT store your variables on a .env file if it's not a local development environment, for other cases, the appropriate method is to add the .env file to a .gitignore and store the variables as [encrypted secrets.](https://docs.github.com/en/actions/security-guides/encrypted-secrets) |
| 65 | +
|
| 66 | +--- |
| 67 | + |
| 68 | +After setting your variables, run `docker-compose up -d` to start the docker. |
| 69 | + |
| 70 | +When docker finished their work (which can take a few minutes the first time, depending on your connection and machine) by opening your browser through http://localhost:8000, you should see the WordPress default installation screen. |
| 71 | + |
| 72 | +Finish WordPress installation and in your terminal, cd the root project folder again type `cd ..` to start working on your plugins and/or themes. |
| 73 | + |
| 74 | +For using wp-cli, use `docker-compose run --rm wpcli command` as it was added to only run one-off commands |
| 75 | + |
| 76 | +The wp-core is synchronized too, just in case you need to check and/or debug something. |
| 77 | + |
| 78 | +# Contributing and Support |
| 79 | + |
| 80 | +It's **work in progress.** Feel free to contribute informing about [issues](https://github.com/sarahcssiqueira/docker-wordpress/issues) or even through [pull requests](https://github.com/sarahcssiqueira/docker-wordpress/pulls) for improvements. |
| 81 | + |
| 82 | +# Docker WordPress Environment |
| 83 | + |
| 84 | +This is a basic **Docker WordPress Environment** focused on the development of **plugins and themes**, supports [WP-CLI](https://wp-cli.org/), [phpMyAdmin](https://www.phpmyadmin.net/) and [Xdebug](https://xdebug.org/). |
| 85 | + |
| 86 | +## Table of Contents |
16 | 87 |
|
17 | | -## Services |
| 88 | +- [Introduction](#docker-wordpress-environment) |
| 89 | + - [Services](#services) |
| 90 | +- [Requirements](#requirements) |
| 91 | +- [Usage](#usage) |
| 92 | + - [Variables](#variables) |
| 93 | + - [WordPress Debug](#debug) |
| 94 | + - [Xdebug for VSCode](#xdebug) |
| 95 | +- [Contributing and Support](#contributing-and-support) |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +> **Disclaimer:** This project is meant to be used for development purposes only. It's **not** meant to be used in production. |
| 100 | +
|
| 101 | +--- |
| 102 | + |
| 103 | +### Services |
| 104 | + |
| 105 | +Docker services used on [docker-compose. yml](https://github.com/sarahcssiqueira/docker-wordpress/blob/master/docker/docker-compose.yml): |
18 | 106 |
|
19 | 107 | - **db** |
20 | 108 |
|
21 | | -The MYSQL official image |
| 109 | +The MYSQL official image. |
22 | 110 |
|
23 | 111 | - **phpMyAdmin** |
24 | 112 |
|
25 | | -Intended to handle the administration of MySQL, in this case through [localhost:8080/](localhost:8080/). |
| 113 | +Intended to handle the administration of MySQL, in this case through port 80, on browser [localhost:8080/](localhost:8080/). |
26 | 114 |
|
27 | 115 | - **WordPress** |
28 | 116 |
|
29 | | -Uses the official WordPress docker image |
| 117 | +Uses the official WordPress latest docker image. |
30 | 118 |
|
31 | 119 | - **WP-CLI** |
32 | 120 |
|
33 | | -The **wpcli container** was added in order to only run one-off commands. Don’t need it to run as a service, only as a cli tool, for that run: |
| 121 | +The **wpcli container** was added to only run one-off commands. Don’t need it to run as a service, only as a cli tool, for that run: |
34 | 122 |
|
35 | 123 | `docker-compose run --rm wpcli command` |
| 124 | + |
| 125 | +## Requirements |
| 126 | + |
| 127 | +- [Docker](https://www.docker.com/) hub |
| 128 | +- [Xdebug](https://xdebug.org/docs/install) |
| 129 | +- [PHP Debug Extension](https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug) |
| 130 | + |
| 131 | +## Usage |
| 132 | + |
| 133 | +Clone this repository `git clone https://github.com/sarahcssiqueira/docker-wordpress` |
| 134 | +then cd the **docker folder** `cd docker` and set up your chosen variables on the .env file. |
| 135 | + |
| 136 | +### Variables |
| 137 | + |
| 138 | +The variables used for WordPress installation are the following ones, you can use the same or change them, it's up to you. |
| 139 | + |
| 140 | +``` |
| 141 | +MYSQL_DATABASE_NAME=exampledatabase |
| 142 | +MYSQL_USER=exampleuser |
| 143 | +MYSQL_PASSWORD=examplepass |
| 144 | +WORDPRESS_PORT=8000 |
| 145 | +``` |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +> WARNING: DO NOT store your variables on a .env file if it's not a local development environment, for other cases, the appropriate method is to add the .env file to a .gitignore and store the variables as [encrypted secrets.](https://docs.github.com/en/actions/security-guides/encrypted-secrets) |
| 150 | +
|
| 151 | +--- |
| 152 | + |
| 153 | +After setting your variables, run `docker-compose up -d` to start the docker. |
| 154 | + |
| 155 | +When docker finished their work (which can take a few minutes the first time, depending on your connection and machine) by opening your browser through http://localhost:8000, you should see the WordPress default installation screen. |
| 156 | + |
| 157 | +Finish WordPress installation and in your terminal, cd the root project folder again type `cd ..` to start working on your plugins and/or themes. |
| 158 | + |
| 159 | +For using wp-cli, use `docker-compose run --rm wpcli command` as it was added to only run one-off commands |
| 160 | + |
| 161 | +## Debugging in WordPress |
| 162 | + |
| 163 | +The wp-core is synchronized through the docker-composer.yml just in case you need to check and/or debug something. After running `docker-compose up -d`, you will be able to change the [WordPress debug mode](https://wordpress.org/documentation/article/debugging-in-wordpress/) by changing the following lines on the wp-config.php file. |
| 164 | + |
| 165 | +By default, the wp-config.php generated by Docker will look something like this: |
| 166 | + |
| 167 | +``` |
| 168 | +define( 'WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', '') ); |
| 169 | +``` |
| 170 | + |
| 171 | +Replace it with the following: |
| 172 | + |
| 173 | +``` |
| 174 | +define( 'WP_DEBUG', true); |
| 175 | +
|
| 176 | +define( 'WP_DEBUG_LOG' , true ); |
| 177 | +
|
| 178 | +define ( 'WP_DEBUG_DISPLAY', true ); |
| 179 | +``` |
| 180 | + |
| 181 | +More info about **debugging in WordPress** you can find [here](https://wordpress.org/documentation/article/debugging-in-wordpress/). |
| 182 | + |
| 183 | +## Xdebug for VSCode |
| 184 | + |
| 185 | +Xdebug is enabled and configured to work on VSCode using the extension PHP Debug. |
| 186 | + |
| 187 | +### Remote Host Debugging |
| 188 | + |
| 189 | +``` |
| 190 | +"pathMappings": { |
| 191 | + "/var/www/html": "${workspaceFolder}", |
| 192 | +} |
| 193 | +``` |
| 194 | + |
| 195 | +# Contributing and Support |
| 196 | + |
| 197 | +It's **work in progress.** Feel free to contribute informing about [issues](https://github.com/sarahcssiqueira/docker-wordpress/issues) or even through [pull requests](https://github.com/sarahcssiqueira/docker-wordpress/pulls) for improvements. |
0 commit comments