Skip to content

Multi-container Docker infrastructure with WordPress, NGINX, MariaDB, and bonus services. Automated deployment with Docker Compose. 42 School project.

Notifications You must be signed in to change notification settings

whoismtrx/42_Inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Inception

Overview

Inception is a system administration and Docker infrastructure project that builds a complete web application stack using Docker Compose. The project involves setting up a multi-container environment with NGINX, WordPress, MariaDB, and several bonus services, all running in isolated Docker containers with custom configurations. Each service runs in its own container built from Debian Bullseye base images, demonstrating infrastructure-as-code principles and containerization best practices.

This project emphasizes understanding Docker networking, volume management, service orchestration, and secure configuration of production-grade web services.

Key Features

Multi-Container Architecture: Orchestrated stack of 8 services using Docker Compose
Custom Docker Images: All services built from penultimate stable Debian (Bullseye)
TLS/SSL Security: NGINX configured with TLSv1.3 and self-signed certificates
Persistent Storage: Docker volumes with local bind mounts for data persistence
WordPress CMS: Full WordPress installation with WP-CLI automation
Database Management: MariaDB with secure installation and user management
Redis Caching: WordPress object caching with Redis integration
FTP Server: vsftpd for secure file transfers to WordPress volume
Database GUI: Adminer for web-based database administration
Container Monitoring: cAdvisor for real-time resource usage monitoring
Static Website: Additional static site served on separate port
Environment Variables: Secure configuration through .env file
Automated Setup: Complete infrastructure provisioning with single command

Architecture

Core Services (Mandatory)

1. NGINX (Port 443, 8081)

  • Reverse proxy with TLSv1.3 encryption
  • Serves WordPress via FastCGI (PHP-FPM)
  • Static website hosting on port 8081
  • Self-signed SSL certificates
  • Custom domain name configuration

2. WordPress (Port 9000)

  • PHP 7.4-FPM with FastCGI
  • WP-CLI for automated installation
  • Two users (admin + regular user)
  • Redis object caching enabled
  • Persistent volume storage

3. MariaDB (Port 3306)

  • Database server for WordPress
  • Automated secure installation
  • Custom database and user creation
  • Data persistence via volume
  • Network isolation (not exposed externally)

Bonus Services

4. Redis (Port 6379)

  • WordPress object caching
  • php-redis extension
  • Improves WordPress performance

5. FTP Server (Port 21)

  • vsftpd daemon
  • Access to WordPress volume
  • User authentication via environment variables

6. Static Website (Port 8081)

  • Simple static HTML site
  • Separate from WordPress
  • Demonstrates multi-service hosting

7. Adminer (Port 3307)

  • Lightweight database management interface
  • Web-based MariaDB administration
  • Alternative to phpMyAdmin

8. cAdvisor (Port 8080)

  • Container resource monitoring
  • Real-time performance metrics
  • CPU, memory, network, disk statistics

Getting Started

Prerequisites

  • Docker Engine
  • Docker Compose
  • GNU Make
  • Linux/Unix system (tested on Debian-based distributions)

Installation

git clone https://github.com/whoismtrx/42_Inception.git inception
cd inception
make

Environment Variables

Create a .env file in srcs/ directory with the following variables:

# Domain
DOMAIN_NAME=your-login.42.fr

# MariaDB
MARIADB_DATABASE=wordpress
MARIADB_USER=wpuser
MARIADB_USER_PASSWORD=secure_password
MARIADB_ROOT_PASSWORD=root_password

# WordPress Admin
WORDPRESS_ADMIN=admin
WORDPRESS_ADMIN_PASSWORD=admin_password
WORDPRESS_ADMIN_EMAIL=admin@example.com

# WordPress User
WORDPRESS_USER=user
WORDPRESS_USER_EMAIL=user@example.com
WORDPRESS_USER_PASSWORD=user_password

# FTP
FTP_USER=ftpuser
FTP_PASSWORD=ftp_password

Accessing Services

Once running, access the services at:

  • WordPress: https://your-login.42.fr
  • Static Website: http://localhost:8081
  • Adminer: http://localhost:3307
  • cAdvisor: http://localhost:8080
  • FTP: ftp://localhost:21

Management Commands

# Stop all containers
make stop

# Stop containers and remove volumes
make stop_volume

# Clean everything (containers, images, volumes)
make clean

# Rebuild and restart
make re

Service Details

NGINX Configuration

  • TLS Version: TLSv1.3 only (most secure)
  • SSL Certificate: Self-signed (generated during build)
  • FastCGI: Proxies PHP requests to WordPress container
  • Virtual Hosts: Supports multiple server blocks
  • Static Files: Serves static content efficiently

WordPress Setup

Automated using WP-CLI:

  1. Downloads latest WordPress core
  2. Creates wp-config.php with database credentials
  3. Installs WordPress with admin user
  4. Creates additional regular user
  5. Configures Redis caching
  6. Installs and activates Redis Cache plugin
  7. Sets proper file permissions

MariaDB Security

Automated secure installation:

  • Removes anonymous users
  • Disables remote root login
  • Removes test database
  • Creates WordPress database and user
  • Grants appropriate privileges
  • Binds to all interfaces for container networking

Volume Management

Two persistent volumes:

  • mariadb: Stores database files at /home/orekabe/data/mariadb
  • wordpress: Stores WordPress files at /home/orekabe/data/wordpress

Volumes use local driver with bind mounts for data persistence across container restarts.

Docker Networking

All services run on the inception network:

  • Internal DNS resolution (services communicate by container name)
  • Isolated from host network (except exposed ports)
  • MariaDB and Redis not exposed externally (security best practice)

Technical Highlights

Container Build Process

Each Dockerfile follows best practices:

  • Based on Debian Bullseye (stable)
  • Minimal layers for smaller image size
  • No latest tags (version pinning)
  • Services run as foreground processes
  • Health checks and restart policies

Service Dependencies

nginx → wordpress → mariadb
         ↓
       redis
         
ftp → wordpress volume

adminer → mariadb

cadvisor → all containers

Security Considerations

  • TLSv1.3 encryption for HTTPS
  • No hardcoded passwords (environment variables)
  • Database not exposed to host
  • Secure MariaDB installation
  • Container isolation
  • Least privilege principle

Project Structure

inception/
├── Makefile                           # Build and deployment automation
├── srcs/
│   ├── docker-compose.yml             # Service orchestration
│   ├── .env                           # Environment variables (not in repo)
│   └── requirements/
│       ├── mariadb/
│       │   ├── Dockerfile
│       │   └── tools/
│       │       ├── MariaDB_Script
│       │       └── Mysql_Secure_Installation.exp
│       ├── wordpress/
│       │   ├── Dockerfile
│       │   ├── conf/www.conf
│       │   └── tools/WordPress_Script
│       ├── nginx/
│       │   ├── Dockerfile
│       │   └── conf/nginx.conf
│       └── bonus/
│           ├── redis/
│           │   ├── Dockerfile
│           │   └── tools/Redis_Script
│           ├── ftp/
│           │   ├── Dockerfile
│           │   ├── config/vsftpd.conf
│           │   └── tools/Ftp_Script
│           ├── adminer/
│           │   └── Dockerfile
│           ├── cadvisor/
│           │   └── Dockerfile
│           └── static_website/
│               ├── Dockerfile
│               └── tools/index.html
└── data/                              # Volume mount points (created by Makefile)
    ├── mariadb/
    └── wordpress/

Disclaimer

This repository is for educational purposes only, documenting my work on the 42 curriculum. These solutions are intended as a reference for students who have already completed or are actively working on the project.

About

Multi-container Docker infrastructure with WordPress, NGINX, MariaDB, and bonus services. Automated deployment with Docker Compose. 42 School project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published