https://github.com/joeri-abbo/wpdc-wordpress-docker-compose
Stack for local development of a WordPress project
https://github.com/joeri-abbo/wpdc-wordpress-docker-compose
development docker docker-compose stack wordpress
Last synced: about 2 months ago
JSON representation
Stack for local development of a WordPress project
- Host: GitHub
- URL: https://github.com/joeri-abbo/wpdc-wordpress-docker-compose
- Owner: Joeri-Abbo
- License: mit
- Created: 2022-07-04T20:32:06.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-04T20:36:13.000Z (almost 4 years ago)
- Last Synced: 2025-01-15T04:30:10.416Z (over 1 year ago)
- Topics: development, docker, docker-compose, stack, wordpress
- Language: Shell
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WPDC - WordPress Docker Compose
Easy WordPress development with Docker and Docker Compose.
With this project you can quickly run the following:
Contents:
- [Requirements](#requirements)
- [Configuration](#configuration)
- [Installation](#installation)
- [Usage](#usage)
## Requirements
Make sure you have the latest versions of **Docker** and **Docker Compose** installed on your machine.
## Configuration
Copy the example environment into `.env`
```
cp env.example .env
```
Edit the `.env` file to change the default IP address, MySQL root password and WordPress database name.
## Installation
Open a terminal and `cd` to the folder in which `docker-compose.yml` is saved and run:
```
docker-compose up
```
This creates two new folders next to your `docker-compose.yml` file.
* `wp-data` – used to store and restore database dumps
* `wp-app` – the location of your WordPress application
The containers are now built and running. You should be able to access the WordPress installation with the configured IP
in the browser address. By default it is `http://127.0.0.1`.
For convenience you may add a new entry into your hosts file.
## Usage
### Starting containers
You can start the containers with the `up` command in daemon mode (by adding `-d` as an argument) or by using
the `start` command:
```
docker-compose start
```
### Stopping containers
```
docker-compose stop
```
### Removing containers
To stop and remove all the containers use the`down` command:
```
docker-compose down
```
Use `-v` if you need to remove the database volume which is used to persist the database:
```
docker-compose down -v
```
### Project from existing source
Copy the `docker-compose.yml` file into a new directory. In the directory you create two folders:
* `wp-data` – here you add the database dump
* `wp-app` – here you copy your existing WordPress code
You can now use the `up` command:
```
docker-compose up
```
This will create the containers and populate the database with the given dump. You may set your host entry and change it
in the database, or you simply overwrite it in `wp-config.php` by adding:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
### Creating database dumps
```
./export.sh
```
### Developing a Theme
Configure the volume to load the theme in the container in the `docker-compose.yml`:
```
volumes:
- ./theme-name/trunk/:/var/www/html/wp-content/themes/theme-name
```
### Developing a Plugin
Configure the volume to load the plugin in the container in the `docker-compose.yml`:
```
volumes:
- ./plugin-name/trunk/:/var/www/html/wp-content/plugins/plugin-name
```
### WP CLI
The docker compose configuration also provides a service for using
the [WordPress CLI](https://developer.wordpress.org/cli/commands/).
Sample command to install WordPress:
```
docker-compose run --rm wpcli wp core install --url=http://localhost --title=test --admin_user=admin --admin_email=test@example.com
```
Or to list installed plugins:
```
docker-compose run --rm wpcli wp plugin list
```
For an easier usage you may consider adding an alias for the CLI:
```
alias wp="docker-compose run --rm wpcli"
```
This way you can use the CLI command above as follows:
```
wp plugin list
```
### phpMyAdmin
You can also visit `http://127.0.0.1:8080` to access phpMyAdmin after starting the containers.
The default username is `root`, and the password is the same as supplied in the `.env` file.
### nginx
You can enable the nginx reverse proxy to serve the WordPress application.
To do this you need to uncomment the `nginx` section in the `docker-compose.yml` file.
Do not forget to change the ip in the wp service
Then you can start the containers with the `up` command:
```
docker-compose build --no-cache && docker-compose up
```