A small multi-container infrastructure built from scratch with Docker and
docker compose. It runs a WordPress site behind NGINX with TLS, backed by a
MariaDB database, each in its own container built from a hand-written Dockerfile
(no prebuilt application images). Built as the 42 "Inception" project.
Three services on a private Docker network:
- nginx is the only entrypoint, exposed on port
443with TLS. A self-signed certificate is generated at build time. It proxies PHP requests to WordPress. - wordpress runs WordPress on PHP-FPM. It reads its database credentials and authentication salts from the environment.
- mariadb stores the WordPress data. An entrypoint script initialises the database and users on first start.
WordPress files and the database live on named volumes so data survives a restart.
client --443--> nginx --9000--> wordpress --3306--> mariadb
Made and tested on Linux only. You need Docker and the docker compose
plugin. The containers are built from debian:12 images.
-
Generate
src/.envwith fresh WordPress salts:make salts
This creates
src/.envfrom the template on first run. Then open it and set the database name/user/password and the MariaDB root password. The domain isccolin.42.fr. -
Point the domain at localhost so the browser reaches nginx. Add a line to
/etc/hosts:127.0.0.1 ccolin.42.fr
The WordPress and database data are bind-mounted under ~/data, which make
creates automatically.
make # build (if needed) and start the stack
make down # stop the containers
make build # rebuild the images from scratch
make clean # stop, remove the volumes and the ~/data files (uses sudo)
make re # full rebuildThen open https://ccolin.42.fr in a browser. The certificate is self-signed, so
you will get a one-time browser warning to accept.
MIT, see LICENSE.