42_Inception

Docker infrastructure with NGINX, WordPress, and MariaDB, using Docker Compose and custom volumes. Includes dedicated containers and TLS security.

Stars
2
Committers
1

Inception 100/100

Table of Contents

Overview

The Inception project involves setting up a small infrastructure using Docker and Docker Compose within a Virtual Machine, with a focus on learning how to manage multiple services—such as NGINX, WordPress, and MariaDB—each running in dedicated containers, all orchestrated by Docker Compose.

Guidelines

Setup and Structure:

  • All project files must be inside a srcs directory.
  • A Makefile is required at the root level to build and run the entire application.
  • Use Docker Compose to manage your services, with each service having its own Dockerfile.
  • Containers should use the latest stable version of Alpine or Debian.

Forbidden:

  • Using pre-built Docker images from Docker Hub.
  • Infinite loops or hacky patches in the entrypoint of the Dockerfile.
  • Storing passwords or sensitive information directly in Dockerfiles.

Allowed:

  • Environment variables stored in a .env file.
  • Docker secrets for managing sensitive data.
  • Custom domain setup, e.g., login.42.fr, pointing to your local IP.

Features

  • NGINX service: Configured with TLSv1.2 or TLSv1.3.
  • WordPress service: Running with php-fpm, without NGINX.
  • MariaDB service: Configured separately, without NGINX.
  • TLS/SSL configured via NGINX as the single entry point through port 443.
  • Dedicated volumes for WordPress files and database.

Execution

To build and run the project, navigate to the root directory and run:

make

Tests

TLS/SSL:

openssl s_client -connect localhost:443
# Look in the output for the line with “Protocol” followed by the type of protocol used
# If you try any other port, the output should be an error

PORTS: nginx connects to wordpress via port 9000

docker exec -it nginx nc -zv wordpress 9000
# [SUCCESS MESSAGE]: Connection to wordpress (xxx.x.x.x) 9000 port [tcp/*] succeeded!
# [ERROR MESSAGE]: OCI runtime exec failed: exec failed: unable to start container process: exec: "nc"...
# If the error occurs, it means netcat isn't installed in the Docker container. To resolve this, run:
docker exec -it nginx bash
apt-get update && apt-get install -y netcat
docker exec -it nginx nc -zv wordpress 9000
exit
# Now, try the initial command again:
docker exec -it nginx nc -zv wordpress 9000

wordpress connects to mariadb via port 3306

docker exec -it wordpress nc -zv mariadb 3306
# [SUCCESS MESSAGE]: Connection to mariadb (xxx.x.x.x) 3306 port [tcp/mysql] succeeded!
# [ERROR MESSAGE]: OCI runtime exec failed: exec failed: unable to start container process: exec: "nc"...
# If the error occurs, it means netcat isn't installed in the Docker container. To resolve this, run:
docker exec -it wordpress bash
apt-get update && apt-get install -y netcat
docker exec -it wordpress nc -zv mariadb 3306
exit
# Now, try the initial command again:
docker exec -it wordpress nc -zv mariadb 3306

MARIADB:

docker exec -it mariadb bash
mariadb
SHOW DATABASES;
USE <database_name>;
SHOW TABLES;
SELECT * FROM <table_name>;

Links to Study

Grade Lang Type Links and Subjects
🇺🇸 🔖 Debian Versions
🇺🇸 📚 Docker Concepts
⭐⭐ 🇺🇸 📄 42 Inception Guide - Part 1
⭐⭐ 🇺🇸 📄 42 Inception Guide - Part 2
🤩 🇧🇷 📹 Docker Essencial: Docker para Iniciantes
⭐⭐ 🇺🇸 📹 Docker

✅ OK | ⭐ Good | ⭐⭐ VeryGood | 🤩 Amazing | 🔖 Bookmarked2Read 📄 Blog | 💭 Chat | 📹 Video | 📚 Book & Scientific Papers