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.
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.
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.
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.
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.
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.
-
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
-
Clone the repository:
git clone https://github.com/jesuismarie/Inception.git cd inception -
Configure the
.envfile:- The
.envfile is located in thesrcsdirectory 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>
- The
-
Update the
/etc/hostsfile:- Open the file with superuser privileges:
sudo nano /etc/hosts
- Add the following line, replacing
<your-login>with your login andx.x.x.xwith 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.
- Open the file with superuser privileges:
-
Build and start the containers using the Makefile:
make
-
Access the infrastructure:
- Visit
https://<your-login>.42.frto view the WordPress site.
- Visit
- 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
- 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.