-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Docker Compose Configuration for WordPress Setup (#153)
* Added wordpress example using docker compose with nginx and mysql * Update README.md
- Loading branch information
1 parent
7ca072b
commit 3796ef1
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
## 🌟 WordPress Wonderland with MySQL 🌈 | ||
|
||
Embark on an exhilarating journey into the WordPress Wonderland, now powered by the enchanting MariaDB! 🚀 This example brings to life a captivating WordPress setup, with a dash of magic from MariaDB. Feel free to swap the enchantment to MySQL by simply unraveling a line in the mystical `compose.yaml` file. | ||
|
||
### ✨ Project Structure | ||
|
||
```plaintext | ||
. | ||
├── compose.yml # 🌐 Docker Compose configuration orchestrating the WordPress magic. | ||
├── .env # 🗝️ Environment file holding configuration secrets for MySQL/MariaDB. | ||
├── nginx/ # 🌐 Nginx configuration directory, shaping the entrance to the WordPress realm. | ||
│ └─ default.conf # 🖌️ Custom Nginx configuration, optimizing the front-end experience. | ||
├── wordpress/ # 🌐 WordPress configuration directory, defining the ambiance of the digital space. | ||
│ └─ 000-default.conf # 🖌️ Tailored WordPress configuration for a rich and engaging content experience. | ||
├── db/ # 🌐 MySQL/MariaDB initialization script directory, setting the stage for database marvels. | ||
│ └─ init.sql # 🖌️ MySQL/MariaDB initialization script, creating the enchanted database realm. | ||
``` | ||
|
||
### 🎭 `compose.yml` - The Magic Potion | ||
|
||
```yaml | ||
version: '3' | ||
|
||
services: | ||
nginx: | ||
image: nginx:alpine3.18-slim | ||
ports: | ||
- "80:80" | ||
... | ||
wordpress: | ||
image: wordpress:latest | ||
restart: always | ||
... | ||
db: | ||
# 🧙♀️ MariaDB image supporting both amd64 & arm64 architecture | ||
image: mariadb:11.0.3 | ||
# 🧙♂️ If you fancy MySQL, just uncomment the line below | ||
# image: mysql:8.1.0 | ||
... | ||
``` | ||
|
||
### 🚀 Deploy with Docker Spells | ||
|
||
```bash | ||
docker-compose up -d | ||
``` | ||
|
||
Watch in awe as a network and a magical volume come to life, deploying the enchanted containers... | ||
|
||
```bash | ||
✔ Network compose-wordpress-mysql_default Created 0.0s | ||
✔ Volume "compose-wordpress-mysql_db-data" Created 0.0s | ||
✔ Container compose-wordpress-mysql-db-1 Started 0.0s | ||
✔ Container compose-wordpress-mysql-wordpress-1 Started 0.0s | ||
✔ Container compose-wordpress-mysql-nginx-1 Started 0.1s | ||
``` | ||
|
||
### ✨ Expected Spellbinding Result | ||
|
||
Peer into the mystic realm and inspect the port mapping: | ||
|
||
```bash | ||
$ docker-compose ps | ||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS | ||
compose-wordpress-mysql-db-1 mariadb:11.0.3 "docker-entrypoint.s…" db About a minute ago Up About a minute 3306/tcp | ||
compose-wordpress-mysql-nginx-1 nginx:alpine3.18-slim "/docker-entrypoint.…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp | ||
compose-wordpress-mysql-wordpress-1 wordpress:6.3.1-php8.2 "docker-entrypoint.s…" wordpress About a minute ago Up About a minute 80/tcp | ||
``` | ||
|
||
Take a magic carpet ride to `http://localhost:80` in your web browser to witness the enchanting WordPress realm. | ||
|
||
![WordPress](./output.jpg) | ||
|
||
### 🛑 Stop the Magic, Remove the Spellbound Containers | ||
|
||
```bash | ||
docker-compose down | ||
``` | ||
|
||
To erase all traces of the enchanted WordPress data, including the named volumes: | ||
|
||
```bash | ||
docker-compose down -v | ||
``` | ||
|
||
Your WordPress Wonderland with MariaDB or MySQL is now ready for you to shape and mold as you please. 🌟 Let the creativity soar, and may your digital adventures be as boundless as the stars! 🌌 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: '3' | ||
|
||
services: | ||
nginx: | ||
image: nginx:alpine3.18-slim | ||
depends_on: | ||
- wordpress | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- ./nginx:/etc/nginx/conf.d | ||
|
||
wordpress: | ||
image: wordpress:6.3.1-php8.2 | ||
restart: always | ||
environment: | ||
WORDPRESS_DB_HOST: db | ||
WORDPRESS_DB_USER: root | ||
WORDPRESS_DB_PASSWORD: example | ||
WORDPRESS_DB_NAME: wordpress | ||
volumes: | ||
- ./wordpress:/var/www/html | ||
depends_on: | ||
- db | ||
|
||
db: | ||
image: mariadb:11.0.3 | ||
environment: | ||
MARIADB_ROOT_PASSWORD: example | ||
MARIADB_DATABASE: wordpress | ||
volumes: | ||
- db-data:/var/lib/mysql | ||
- ./db:/docker-entrypoint-initdb.d | ||
|
||
volumes: | ||
db-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE DATABASE IF NOT EXISTS wordpress; | ||
USE wordpress; | ||
|
||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'example' WITH GRANT OPTION; | ||
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# nginx/default.conf | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
proxy_pass http://wordpress:80; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /var/www/html | ||
|
||
ErrorLog ${APACHE_LOG_DIR}/error.log | ||
CustomLog ${APACHE_LOG_DIR}/access.log combined | ||
</VirtualHost> |