Containerized WordPress stack with Nginx, MariaDB, and optional Redis/Adminer, built from custom Docker images and configured via environment variables.
42 curriculum project: design a small infrastructure with Docker and Docker Compose using custom service images (no all-in-one prebuilt stack). The stack runs locally and models a production-style setup: separate web, application (PHP-FPM), and database services, plus optional cache and admin UI.
- Infrastructure as code — Docker Compose, custom images for Nginx, WordPress (PHP-FPM + WP-CLI), MariaDB, Redis, Adminer.
- Scripted provisioning — MariaDB DB/user/permissions and WordPress install (site, admin, extra user) via Bash + env vars.
- Environment-driven config —
.envfor domain, credentials, feature flags; persistent volumes for MariaDB and WordPress data under/home/$LOGIN/data.
- Core: Nginx (HTTPS), WordPress/PHP-FPM, MariaDB; persistent volumes for DB and WordPress.
- Bonus (optional): Redis (WordPress cache), Adminer (DB UI via Nginx at
https://<DOMAIN_NAME>/adminerwhenENABLE_BONUS=trueand bonus compose is used).
Both the core stack and the bonus stack were tested successfully locally.
Docker, Docker Compose (multi-file). Services: Nginx, PHP 7.4 + PHP-FPM, MariaDB, Redis (optional), Adminer (optional). Base: debian:bullseye. Tooling: Bash, WP-CLI, OpenSSL (self-signed cert).
- Nginx — Port 443, self-signed TLS,
server_namefromDOMAIN_NAME; proxies PHP to WordPress container (port 9000). - WordPress — PHP-FPM; entrypoint script downloads WP, configures
wp-config.php(DB env vars), installs site (DOMAIN_NAME, WP_TITLE, admin/user from WP_* env vars); whenENABLE_BONUS=true, configures Redis cache plugin. - MariaDB — Init script sets root password, creates DB and user from
MYSQL_*env vars. - Redis (bonus) — Cache backend; health-checked before WordPress enables cache.
- Adminer (bonus) — DB UI exposed via Nginx when bonus enabled.
- Networking & storage — All on network
inception; volumesmariadbandwordpressbound to/home/$LOGIN/data/mariadband/home/$LOGIN/data/wordpress.
.
├── Makefile
└── srcs
├── docker-compose.yml # Core: nginx, wordpress, mariadb
├── docker-compose.bonus.yml # Bonus: redis, adminer
├── .env.example
└── requirements
├── mariadb (Dockerfile, conf/mdb-conf.sh)
├── nginx (Dockerfile, conf/nginx.conf, conf/bonus/adminer.conf, tools/docker-entrypoint.sh)
├── wordpress (Dockerfile, conf/wp_conf.sh)
└── bonus
├── redis (Dockerfile, conf/redis.conf)
└── adminer (Dockerfile)
- Service separation — Nginx, WordPress, MariaDB, Redis, Adminer in separate containers.
- Scripted provisioning — WordPress and MariaDB fully initialized from env vars (reproducible, more Bash).
- Env-only config — No hardcoded secrets; variable set documented in Installation below.
- Bonus toggle —
ENABLE_BONUS+docker-compose.bonus.ymlto enable Redis and Adminer without changing base stack.
- Core stack — Built and tested locally (e.g.
DOMAIN_NAME=tjoyeux.42.fr,127.0.0.1 tjoyeux.42.frin/etc/hosts, access viahttps://tjoyeux.42.frwith self-signed cert warning accepted). - Bonus stack — Tested successfully; Adminer reachable at
https://<DOMAIN_NAME>/adminer; Redis validated withredis-cli pingfrom inside the Redis container. - Metrics — None collected; focus is on architecture and composition.
WordPress (public homepage) — https://<DOMAIN_NAME>/:
Adminer (bonus mode) — https://<DOMAIN_NAME>/adminer:
Prerequisites: Docker, Docker Compose, make.
The stack depends on a non-versioned srcs/.env. Copy the example and edit:
cp srcs/.env.example srcs/.envRequired: LOGIN (host paths), DOMAIN_NAME, MYSQL_ROOT_PASSWORD, MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD, WP_TITLE, WP_ADMIN_N, WP_ADMIN_P, WP_ADMIN_E, WP_U_NAME, WP_U_EMAIL, WP_U_PASS, WP_U_ROLE, ENABLE_BONUS. Volumes use /home/$LOGIN/data/mariadb and /home/$LOGIN/data/wordpress.
Local access: Map DOMAIN_NAME to 127.0.0.1 in /etc/hosts (e.g. 127.0.0.1 your-login.42.fr). Nginx uses a self-signed certificate — accept the browser warning for https://<DOMAIN_NAME>.
Commands (from repo root):
| Action | Command |
|---|---|
| Start core stack | make up |
| Start with bonus (Redis, Adminer) | make bonus |
| Stop | make stop |
| Clean (destructive) | make clean / make prune |
When bonus is enabled, Adminer is at https://<DOMAIN_NAME>/adminer.
- Architecture diagram in docs;
ENVIRONMENT.mdfor env vars. - Makefile targets for logs (e.g.
make logs-wordpress) and single-service reset. - Production use: replace self-signed cert; harden Nginx (headers, rate limiting).


