Skip to content

Virtualizing several Docker images (Nginx, Wordpress, MariaDB and more ...), creating them in your new personal virtual machine.

Notifications You must be signed in to change notification settings

jesuismarie/Inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Inception

Introduction

The Inception project is designed to introduce the concept of containerized infrastructure. The goal is to create a small, efficient setup of Docker containers using Docker Compose, adhering to specific rules and best practices. Each service runs in its dedicated container, and the entire setup is managed within a virtual machine environment.

What is Docker?

Docker is a platform that allows developers to package applications and their dependencies into lightweight, portable containers. These containers run consistently across different environments, eliminating the "it works on my machine" problem. Docker simplifies software delivery by isolating applications from their underlying infrastructure.

What is Docker Compose?

Docker Compose is a tool for defining and managing multi-container Docker applications. Using a docker-compose.yml file, you can configure your services, networks, and volumes in a declarative format. Docker Compose simplifies the process of running complex setups by managing multiple containers with a single command.

Key Concepts

Docker Image

A Docker image is a lightweight, standalone, and executable package that includes everything needed to run a piece of software. This includes the application code, runtime, libraries, environment variables, and configurations. Docker images are used to create containers.

Docker Volume

A Docker volume is a mechanism for persisting data generated by and used by Docker containers. Volumes allow you to share data between containers and the host system, ensuring that important data is not lost when containers are removed or recreated.

Project Structure

The project directory is structured as follows:

Desktop/42-Projects/Inception/
├── Makefile
└── srcs
    ├── docker-compose.yml
    ├── .env
    └── requirements
        ├── mariadb
        │   ├── conf
        │   │   └── 50-server.cnf
        │   ├── Dockerfile
        │   └── tools
        │       └── run_mariadb.sh
        ├── nginx
        │   ├── conf
        │   │   └── default.conf
        │   ├── Dockerfile
        │   └── tools
        │       └── run_nginx.sh
        └── wordpress
            ├── Dockerfile
            └── tools
                └── run_wordpress.sh
  • Makefile: Automates the building and running of the Docker Compose setup.
  • docker-compose.yml: Defines the services, networks, and volumes.
  • .env: Stores environment variables for configuration.
  • requirements/: Contains subdirectories for each service (e.g., MariaDB, NGINX, WordPress), along with their respective Dockerfiles and configurations.

Usage

Steps

  1. Before running Inception, ensure that you have the necessary dependencies installed. You may need to install the following packages:

    sudo apt-get update
    sudo apt-get install build-essential -y
    sudo apt-get install docker docker-compose -y
  2. Clone the repository:

    git clone https://github.com/jesuismarie/Inception.git
    cd inception
  3. Configure the .env file:

    • The .env file is located in the srcs directory and stores environment variables.
    • Example structure:
      USERNAME=<your-login>
      DOMAIN_NAME=<your-login>.42.fr
      CERTS=/etc/nginx/ssl/<your-login>-selfsigned.crt
      KEYOUT=/etc/nginx/ssl/<your-login>-selfsigned.key
      
      MYSQL_ROOT_PASSWORD=<root-password>
      MYSQL_USER=<db-username>
      MYSQL_PASSWORD=<db-password>
      WORDPRESS_DB_NAME=<db-name>
      
      MYSQL_USER=<db-username>
      MYSQL_DATABASE=<db_name>
      MYSQL_PASSWORD=<db-password>
      MYSQL_HOSTNAME=mariadb
      MYSQL_ROOT_PASSWORD=<db-root-password>
      
      WORDPRESS_TITLE=<wp-title>
      WORDPRESS_ROOT_USERNAME=<wp-admin-username>
      WORDPRESS_ROOT_EMAIL=<wp-root-mail>
      WORDPRESS_ROOT_PASSWORD=<wp-root-password>
      
      WORDPRESS_USER_USERNAME=<wp-user-username>
      WORDPRESS_USER_EMAIL=<wp-user-mail>
      WORDPRESS_USER_PASSWORD=<wp-user-password>
      
  4. Update the /etc/hosts file:

    • Open the file with superuser privileges:
      sudo nano /etc/hosts
    • Add the following line, replacing <your-login> with your login and x.x.x.x with the IP address of your virtual machine:
      x.x.x.x <your-login>.42.fr www.<your-login>.42.fr
      
    • Save and exit the file.
  5. Build and start the containers using the Makefile:

    make
  6. Access the infrastructure:

    • Visit https://<your-login>.42.fr to view the WordPress site.

Additional Commands

  • Stop containers and clean up all containers:
    make down
  • Sart containers:
    make start
  • Stop containers:
    make stop
  • Clean up all containers, volumes and network:
    make fclean
  • Rebuild the setup:
    make re

Project Features

Mandatory

  • NGINX: Secure access using TLSv1.2 or TLSv1.3 (port 443).
  • WordPress: PHP-FPM configured for content management.
  • MariaDB: Backend database for WordPress.
  • Volumes: Separate storage for WordPress files and database.
  • Network: Custom Docker network connecting all containers.

About

Virtualizing several Docker images (Nginx, Wordpress, MariaDB and more ...), creating them in your new personal virtual machine.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published