Skip to content

12Ivan03/inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been created as part of the 42 curriculum by ipavlov.

Inception

Description

This project has been created as part of the 42 curriculum by ipavlov. This project aims to broaden your knowledge of system administration by using Docker. You will virtualise several Docker images, creating them in your new personal virtual machine.

🐳 Inception - Dockerized WordPress Infrastructure

This project sets up a complete web infrastructure using Docker and Docker Compose, including:

  • NGINX (with SSL/TLS)
  • WordPress (PHP-FPM)
  • MariaDB
  • Persistent storage using volumes

🚀 Overview

The architecture follows a modular container-based design:

Browser → NGINX → WordPress (PHP-FPM) → MariaDB

  • NGINX handles HTTPS requests
  • WordPress serves dynamic content via PHP-FPM
  • MariaDB stores all application data
  • Volumes ensure data persistence

📁 Project Structure

inception/
├── Makefile
├── srcs/
│ ├── docker-compose.yml
│ ├── .env
│ └── requirements/
│ ├── nginx/
│ │ ├── Dockerfile
│ │ └── conf/default.conf
│ ├── wordpress/
│ │ ├── Dockerfile
│ │ └── tools/setup.sh
│ └── mariadb/
│ ├── Dockerfile
│ └── tools/setup.sh

⚙️ Instructions

1. Clone the repository

git clone https://github.com/12Ivan03/inception.git
cd inception

2. Configure environment variables & Secrets

2.1

Add and edit the .env file inside srcs/:

DOMAIN_NAME=<name>.42.fr

MYSQL_DATABASE=
MYSQL_USER=
MYSQL_ROOT_PASSWORD=

WORDPRESS_TITLE=
WORDPRESS_ADMIN_USER=
WORDPRESS_ADMIN_EMAIL=

WORDPRESS_USER=
WORDPRESS_USER_EMAIL=

2.2

Configure secrets

Create a secrets/ folder at the root of the project:

mkdir secrets

Add the following files

secrets/db_password.txt
secrets/db_root_password.txt
secrets/wp_ad_password.txt
secrets/wp_us_password.txt

Each file should contain only the password, for example:

my_password

3. Update the hosts file

Add this line to /etc/hosts:

127.0.0.1 <name>.42.fr

4. Create persistent data folders

mkdir -p /Users/your-username/data

5. Build and start the project

make

6. Access the website

https://<your-username>.42.fr

⚠️ A self-signed certificate warning is expected.


7. Authentication

WordPress Login:

https://your-username.42.fr/wp-login.php

Admin Dashboard:

https://your-username.42.fr/wp-admin


8. Common Commands

  • make / make up → start containers
  • make down → stop containers (keeps data)
  • make clean → remove containers and networks
  • make fclean → full cleanup (⚠️ removes images and cache)
  • make re → rebuild everything

🧠 Architecture & Communication

  • NGINX listens on port 443 and handles HTTPS requests
  • It forwards PHP requests to the WordPress container via FastCGI
  • WordPress communicates with MariaDB using the service name mariadb
  • Docker provides internal DNS so services can resolve each other by name

1. Services

🔹 NGINX

  • Handles HTTPS traffic (port 443)
  • Uses a self-signed SSL certificate
  • Forwards PHP requests to WordPress 🔹 WordPress
  • Runs with PHP-FPM (port 9000)
  • Installed automatically using wp-cli
  • Creates admin + normal user 🔹 MariaDB
  • Stores WordPress data
  • Initialised via setup script
  • Persistent storage via volume

2. Volumes & Persistence

The project uses bind-mounted volumes to persist data:

  • MariaDB stores its database in /var/lib/mysql
  • WordPress stores its files in /var/www/html

These are mapped to host directories:

/Users/your-username/data/mariadb /Users/your-username/data/wordpress

This ensures that:

  • Data is not lost when containers are removed
  • The system survives reboots
  • Files can be inspected directly from the host

Data is stored on the host machine using bind-mounted volumes:

/Users/<your-username>/data/mariadb
/Users/<your-username>/data/wordpress

This ensures:

Data survives container restart Data survives system reboot Easy inspection and debugging


3. Add:

🔐 Security Notes

  • HTTPS enforced using TLS
  • Self-signed certificate generated via OpenSSL
  • No credentials are stored in the repository
  • All sensitive data is stored in .env

4. Testing

Check containers:

docker compose -f srcs/docker-compose.yml ps

Access MariaDB:

docker compose exec mariadb bash
mysql -u root -p

Access WordPress container:

docker compose exec wordpress bash

Resources

Documentation

AI Usage

AI tools (such as ChatGPT) were used during this project to:

  • Clarify Docker concepts and container networking
  • Debug configuration issues (NGINX, WordPress, MariaDB)
  • Improve understanding of best practices in Dockerfiles and docker-compose

About

This project aims to broaden your knowledge of system administration by using Docker. You will virtualize several Docker images, creating them in your new personal virtual machine.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors