Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inception

Containerized WordPress stack with Nginx, MariaDB, and optional Redis/Adminer, built from custom Docker images and configured via environment variables.


Project context

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.


What this project demonstrates

  • 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.env for domain, credentials, feature flags; persistent volumes for MariaDB and WordPress data under /home/$LOGIN/data.

Features / Scope

  • 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>/adminer when ENABLE_BONUS=true and bonus compose is used).

Both the core stack and the bonus stack were tested successfully locally.


Technical stack

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).


Architecture overview

  • Nginx — Port 443, self-signed TLS, server_name from DOMAIN_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); when ENABLE_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; volumes mariadb and wordpress bound to /home/$LOGIN/data/mariadb and /home/$LOGIN/data/wordpress.

Inception architecture


Repository structure

.
├── 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)

Challenges and technical decisions

  • 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 toggleENABLE_BONUS + docker-compose.bonus.yml to enable Redis and Adminer without changing base stack.

Results / Validation / Metrics

  • Core stack — Built and tested locally (e.g. DOMAIN_NAME=tjoyeux.42.fr, 127.0.0.1 tjoyeux.42.fr in /etc/hosts, access via https://tjoyeux.42.fr with self-signed cert warning accepted).
  • Bonus stack — Tested successfully; Adminer reachable at https://<DOMAIN_NAME>/adminer; Redis validated with redis-cli ping from inside the Redis container.
  • Metrics — None collected; focus is on architecture and composition.

Visual overview

WordPress (public homepage)https://<DOMAIN_NAME>/:

Inception WordPress homepage

Adminer (bonus mode)https://<DOMAIN_NAME>/adminer:

Inception Adminer


Installation / Usage

Prerequisites: Docker, Docker Compose, make.

The stack depends on a non-versioned srcs/.env. Copy the example and edit:

cp srcs/.env.example srcs/.env

Required: 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.


Possible improvements

  • Architecture diagram in docs; ENVIRONMENT.md for 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).

About

Docker-based WordPress infrastructure with Nginx, MariaDB, Redis, and Adminer.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages