Docker-Wordpress-Fpm-Redis-MariaDB-Nginx
Simple docker env, for local development.
About build:
-
composer (Dockerfile, composer.json, project-init and start-entrypoint scripts)
load clean latest wordpress project template if not exists in ./app, or update vendor for plugins and themes (require in composer.json)
-
app (Dockerfile and start-entrypoint)
run after pre-build stage, create wordpress-fpm container and serve by php-fpm (load www.conf, and php.ini from ./php)
- cache (redis-alpine)
-
web (nginx-alpine)
edit default.config.template in ./nginx/templates/
-
adm (adminer)
works with mysql, postgres etc (change driver before login)
- db (MariaDB)
-
example ‘.env’ config for build
.env holds all build env every service (overrites wordpress .env file if exists)
Pre-build stage
Before run you should install docker on your PC.
How install docker, official docs
Checkout docker already installed, just run in terminal and you get docker version info
docker -v
Run composer service before and load wordpress project source (build composer image and load empty wordpress project with required themes and plugins)
docker compose up -d composer
Then remove composer service final pre-build stage
docker compose down --remove-orphans
Workflow
Run docker compose up
docker compose up -d
And now checkout in browser:
Adminer if want edit database manually
Nginx proxy for services (laravel-app)
Wordpress official CMS info
Wordpress access on default port nginx, but serve by php-fpm server, settings edit in www.conf in ./php
Permission problem
You can add root access for your user (host machine)
alpine www-data user assign to 82 id, so create new user with same name group with same id on your host machine (example for ubuntu)
sudo groupadd -g 82 www
sudo useradd -u 82 -g 82 www
Now add your current user (host machine) into www group for full permission
sudo usermod -a -G www [user-name]
Add full permission for your user, use command as root (sudo) -R flag (recursive run)
sudo chown -R [user-name]:www /path/to/your/local/folder
How return default permission
This will return all back, use command as root (sudo) -R flag (recursive run)
sudo chown -R www /path/to/your/local/folder
But for better permission config use security plugins:
All In One WP Security & Firewall, official wordpress plugin
Already include in composer.json
Help tools
- Gitignore generator helps generate gitignore for your lang, ide, or framework.
Описание
Docker build for web: Wordpress fpm, mariadb, redis cache, adminer, nginx