This repository contains the Inception project, a comprehensive assignment from the 42 school curriculum that focuses on deepening understanding of containerization and orchestration with Docker. The project involves setting up a small infrastructure composed of several services in Docker containers, including a web server with PHP, a database, and an admin tool, all managed through Docker-compose. The goal is to practice creating a secure and efficient containerized environment, following the principles of Infrastructure as Code (IaC).
- Web Server: Configured to serve a website or PHP application, encapsulated within its own container.
- Database Server: A separate container running a database service, such as MariaDB, isolated from the other services for security and performance.
- Admin Interface: Tooling like phpMyAdmin set up in another container, providing a web interface for database management.
- Volume Management: Persistent storage solutions for data retention across container restarts and deployments.
- Network Configuration: Custom Docker networks for inter-container communication, enhancing security and connectivity.
- Security Practices: Implementation of security best practices, such as environment variable management, secure passwords, and network policies.
- Docker and Docker-compose: The project relies entirely on Docker for containerization and orchestration.
- Any Unix-based operating system (Linux preferred).
Before launching the project, you need to create a .env file at the root of the project directory to configure the environment variables required for the services. This file should include variables such as database passwords, user names, and any other configurations your services might need. Ensure you set DOMAIN_NAME=localhost in your .env file to properly configure the domain name for the services.
-
Clone the repository:
git clone git@github.com:akhellad/Inception.git
-
Navigate to the project directory:
cd inception -
Create and configure your
.envfile as described in the Configuration section.A template for the
.envfile might look like this:# Environment configuration DOMAIN_NAME=localhost MYSQL_ROOT_PASSWORD=examplepassword MYSQL_USER=exampleuser MYSQL_PASSWORD=exampleuserpassword MYSQL_DATABASE=exampledbMake sure to replace the placeholder values with your actual data.
-
Launch the project:
Using the Makefile, you can build and start all the services with the configured environment variables.
make all
This command will initiate the Docker-compose process, which reads the
docker-compose.ymland.envfiles, building the necessary Docker images, and starting up the containers as defined.
After successfully launching the services:
- Web Server: Your web application will be accessible at
https://localhost. - Admin Interface: To manage the database, access the admin tool (like phpMyAdmin) at
https://localhost:<admin_port>. Be sure to replace<admin_port>with the actual port number you configured in yourdocker-compose.ymlfile.
To clean up your environment, you can use the Makefile commands designed for this purpose:
-
To stop and remove the containers, networks, and volumes:
make down
-
For a full cleanup, including removing all images used by the project:
make fclean
This will ensure that all components related to the project are removed, freeing up your system resources.
This project was meticulously developed by Ahmed Khelladi, as part of the 42 school curriculum. It's a demonstration of leveraging Docker and Docker-compose to craft a fully containerized web application environment, adhering to best practices in security and infrastructure management.