Skip to content

Fernandomr23/inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Inception

Description

Inception is a system administration project designed to deepen knowledge of Docker and virtualization. The goal is to configure a small infrastructure with multiple services under specific rules using Docker Compose. The infrastructure includes:

  • NGINX: Web server with TLSv1.2/TLSv1.3 (port 443).
  • WordPress + PHP-FPM: Content management system.
  • MariaDB: Database management system.

Each service runs in its own Docker container with custom images built from Dockerfiles. Data persists using Docker volumes, and services communicate through a dedicated Docker network.

Instructions

Prerequisites

  • Docker and Docker Compose installed.
  • Root or sudo access to create directories on the host system.
  • A .env file in srcs/ with the required credentials.

Setup

  1. Create the .env file in srcs/ with the following variables:
MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_DATABASE=wordpress
MYSQL_USER=your_user
MYSQL_PASSWORD=your_password
WORDPRESS_DB_HOST=mariadb
WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=your_user
WORDPRESS_DB_PASSWORD=your_password
WORDPRESS_TITLE=My Site
WORDPRESS_ADMIN_USER=admin
WORDPRESS_ADMIN_PASSWORD=admin_password
WORDPRESS_ADMIN_EMAIL=admin@example.com
WORDPRESS_USER=user
WORDPRESS_USER_EMAIL=user@example.com
WORDPRESS_USER_PASSWORD=user_password
DOMAIN_NAME=fmorenil.42.fr
  1. Set up the local domain by adding this line to /etc/hosts:
127.0.0.1    fmorenil.42.fr
  1. Build and run the project:
make

Available Commands

  • make or make all: Build and start all containers.
  • make down: Stop and remove containers.
  • make start: Start stopped containers.
  • make stop: Stop running containers.
  • make logs: Show real-time logs.
  • make clean: Remove containers, networks, and images.
  • make fclean: Full cleanup, including data volumes.
  • make re: Rebuild everything from scratch.

Access

Resources

Documentation

AI Usage

AI tools (GitHub Copilot, ChatGPT) were used for:

  • Researching Docker best practices.
  • Debugging Bash scripts and Dockerfiles.
  • Optimizing NGINX and PHP-FPM configurations.
  • Generating WP-CLI and MariaDB commands.

All generated code was reviewed and adapted to the project’s needs.

Project Description

Docker Usage

  • Service isolation: Each service runs in its own container (MariaDB, WordPress, NGINX).
  • Custom images: Built from Debian Bookworm.
  • Orchestration: Managed with Docker Compose.
  • Persistence: Data stored in Docker volumes.
  • Auto-restart: Containers restart on failure.

Design Choices

  1. Base Image: Debian Bookworm for stability.
  2. Service Separation: Each service in its own container for isolation.
  3. Initialization Scripts: Automates setup for WordPress and MariaDB.
  4. Self-Signed SSL Certificates: Automatically generated for local development.

Comparisons

Virtual Machines vs Docker

Aspect Virtual Machines Docker
Isolation Full OS isolation Process-level
Size GBs (full OS) MBs (app + deps)
Startup Time Minutes Seconds
Resource Usage High Low
Portability Limited High
Usage in Project

Secrets vs Environment Variables

Aspect Secrets Environment Variables
Security Encrypted at rest Visible in logs
Access Mounted files Directly accessible
Rotation Easier Manual
Management Docker Swarm Simple
Usage in Project

Docker Network vs Host Network

Aspect Docker Network Host Network
Isolation ✅ Private network ❌ Shared with host
DNS Resolution ✅ Service names ❌ Requires IPs
Security ✅ Port filtering ⚠️ All ports exposed
Portability ✅ Consistent ⚠️ Host-dependent
Usage in Project

Docker Volumes vs Bind Mounts

Aspect Docker Volumes Bind Mounts
Management ✅ Docker-managed ⚠️ User-managed
Portability ✅ Host-independent ❌ Host-dependent
Performance ✅ Optimized Variable
Backup ✅ Docker commands Manual
Usage in Project

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors