This project builds a small Docker-based infrastructure for the 42 Inception project.
The stack is composed of three isolated services:
- NGINX: HTTPS entry point exposed on port
443 - WordPress + PHP-FPM: application service
- MariaDB: database service used by WordPress
Each service runs in its own container and is built from a dedicated Dockerfile.
.
├── Makefile
├── README.md
├── USER_DOC.md
├── DEV_DOC.md
├── secrets/
│ ├── credentials.txt
│ ├── db_password.txt
│ └── db_root_password.txt
└── srcs/
├── .env
├── docker-compose.yml
└── requirements/
├── mariadb/
│ ├── Dockerfile
│ ├── conf/50-server.cnf
│ └── tools/init.sh
├── nginx/
│ ├── Dockerfile
│ ├── conf/default.conf.template
│ └── tools/script.sh
└── wordpress/
├── Dockerfile
├── conf/www.conf
└── tools/script.shAll services are connected through the custom bridge network inception.
Containers communicate internally by service name:
nginxforwards PHP requests towordpress:9000wordpressconnects tomariadb:3306
Only NGINX is exposed to the host machine.
Persistent data is stored outside the containers through local bind-backed volumes:
/home/${LOGIN}/data/mariadb/home/${LOGIN}/data/wordpress
This keeps the database and WordPress files available after container restarts or rebuilds.
Sensitive data is injected through Docker secrets:
db_passworddb_root_passwordcredentials
These values are mounted inside /run/secrets/ and read by the startup scripts.
Non-sensitive configuration is loaded from srcs/.env.
MariaDB is built from Debian Bookworm and configured with a custom 50-server.cnf.
Main responsibilities:
- initialize the database directory if it does not exist
- create the WordPress database
- create the application user
- set the root password
- start MariaDB with persistent storage
Important file:
srcs/requirements/mariadb/tools/init.sh
Initialization happens only on first run, detected through /var/lib/mysql/mysql.
WordPress runs with PHP-FPM on port 9000.
Main responsibilities:
- wait until MariaDB is available
- read database and WordPress credentials from Docker secrets
- download WP-CLI
- download WordPress core
- generate
wp-config.php - install WordPress
- create an additional WordPress user
- start PHP-FPM in foreground mode
Important files:
srcs/requirements/wordpress/tools/script.shsrcs/requirements/wordpress/conf/www.conf
The installation is skipped if wp-config.php already exists in the persistent volume.
NGINX is the only public entry point of the stack.
Main responsibilities:
- generate a self-signed TLS certificate
- inject the configured domain into the NGINX template
- serve the WordPress files through HTTPS
- pass PHP requests to the WordPress container
Important files:
srcs/requirements/nginx/tools/script.shsrcs/requirements/nginx/conf/default.conf.template
NGINX mounts the WordPress volume in read-only mode.
The expected startup sequence is:
make buildormakecreates the required host directories under/home/${LOGIN}/data.- Docker Compose builds and starts the containers.
mariadbinitializes its data directory and becomes healthy.wordpressstarts only after MariaDB passes the healthcheck.- WordPress waits until the database accepts connections, then installs itself if needed.
nginxstarts and exposes HTTPS on port443.
The file srcs/.env contains non-sensitive values such as:
LOGINDOMAIN_NAMEDB_NAMEDB_USERWP_TITLEWP_ADMIN_USERWP_ADMIN_EMAILWP_USERWP_USER_EMAIL
These variables are shared with the services through env_file.
The stack follows these design choices:
- one process per container
- one
Dockerfileper service - one dedicated internal Docker network
- only one public entry point
- persistent storage outside the container filesystem
- secrets separated from regular configuration
This design keeps the stack simple, traceable, and aligned with the project subject.
The Makefile provides a small workflow wrapper around Docker Compose.
makeormake up: start containersmake build: build and start containersmake down: stop containersmake clean: stop containers and remove Docker volumesmake fclean: remove volumes and host persistent datamake re: full rebuildmake ps: show running containersmake logs: show service logs
The prepare target creates the host data directories before startup.
Useful commands during development:
make ps
make logs
docker compose --env-file srcs/.env -f srcs/docker-compose.yml logs mariadb
docker compose --env-file srcs/.env -f srcs/docker-compose.yml logs wordpress
docker compose --env-file srcs/.env -f srcs/docker-compose.yml logs nginxTo inspect a running container:
docker compose --env-file srcs/.env -f srcs/docker-compose.yml exec mariadb bash
docker compose --env-file srcs/.env -f srcs/docker-compose.yml exec wordpress sh
docker compose --env-file srcs/.env -f srcs/docker-compose.yml exec nginx shTo test HTTPS locally:
curl -k https://brturcio.42.frCurrent technical limitations of this implementation:
- WordPress downloads
wp-cli.pharat container startup, which depends on external network access - secrets are stored locally in files and should not be committed in a real production workflow
- NGINX depends on WordPress startup order, but WordPress does not expose a dedicated healthcheck
- the project uses a self-signed certificate, so browsers will display a warning
If configuration values change, check these areas together:
srcs/.envREADME.mdUSER_DOC.md- domain name configured in
/etc/hosts- sudo vim /etc/hosts
- 127.0.0.1 LOGIN.42.fr
- persistent data paths under
/home/${LOGIN}/data
Keeping names and paths aligned is important to avoid broken mounts, wrong domains, or inconsistent documentation.