Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
NotificationsYou must be signed in to change notification settings

fleblay/42-Inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Infrastructure deployment with Docker

Final Grade :fle-blay's 42 Inception Score

Overview

The goal of this projet is to create an infrastructure of different services running in containers, inside a virtual machine. This infrasctrure allows to access a fully functionnal WordPress website using a regular browser

The following services will be running :

  • NGINX with TLS
  • WordPress + php-fpm
  • MariaDB
  • BONUS : Redis Cache
  • BONUS : FTP Server
  • BONUS : Personal Static WebSite
  • BONUS : Adminer
  • BONUS : Any service with usefull

Constraints

  • Each DockerFile has to be created from scratch : no using DockerFiles from dockerhub
  • The whole project has to start using Make. This means the project structure must rely on :
    • A Makefile on top of...
    • A docker-compose file using various...
    • DockerFiles
  • Abiding by DockerFile best practices is mandatory : PID1, no sleep infinity in scripts, justify exposing ports...

Implemented Solution

The docker-compose file will start the following containers :

  • NGINX : Main ingress point of the infrastructure. Listen https requests on port 443 and proxy passes them to the ad-hoc services. The main goal is to treat requests on .php files for the wordpress website, and send back php-fpm response to the client
  • PHP-FPM : Processes .php files and send back the result. The main goal is to listen for GET/POST requests on the Wordpress .php files, process them and send the result back to NGINX.
  • MariaDB : Database server in charge of storing and retrieving data for the Website (users's posts, images...)
  • Redis Cache : Cache for requests on the website pages. Its role is to speed up the reponse time. Because DB queries and php rendering can be quite long, Redis will store in RAM (and optionnaly on disk) the results of the client requests. If 2 similar requests happen in a short time range, the first one will be treated normally (php + MariaDB), but the second one will be served by Redis, with a copy of the result of the first request.
  • VSFTP : FTP server for updating the Worpress Website files. It provides a simple way (with a ftp client) to modify and update the website content without the need to have acces to the Virtual Machine filesystem.
  • Monitoring system : Node_exporter / Prometheus / Grafana. It provides a monitoring interface with metrics (CPU usage, RAM usage, HDD access) of the Virtual Machine running the containers. It is built on top of 3 containers :
    • Node_exporter : Periodically collects info on ressources usage of the VM and sends them to Prometheus.
    • Prometheus : Gathers info from node_exporter and stores them in a Database. Gives access to current VM info and history to clients, such as Grafana
    • Grafana : Webinterface for reading the VM metrics. It is mainly a dashboard displaying the infos from Prometheus in a user friendly manner. It is accessible through port 3000
  • NodeJS : FTP server built with ExpressJS framework on the NodeJS environment. Serves the Personal Website files (completely different from the WordPress one)

Schematics and Diagrams

Usage

Dependencies

First and foremost, make sure you have the following packages installed on your machine :

  • Docker
  • Make

Install

Clone the repo on your machine and go to project directory :

  git clone https://github.com/fleblay/42-Inception && cd !#:2:t

Lauch the docker infra using the Makefile provided :

  make

Access the Website onlocalhostNote : You might have to tweak your browser to access it because the SSL certificate is self-signed.

ROX (Return On Experience)

Knowledge acquired during this project

  • Docker :
    • Running containers using prebuilt images from the hub
    • Creating custom images with DockerFiles following Docker best practices (PID 1, using the build cache correctly, CMD versus ENTRYPOINT commands...
    • Setting up volumes and networks between the HOST and the containers to allow them to communicate and read/write data to the filesystem
    • Deploying a complete infrastructure with the Docker Compose and the yaml files
    • Improving knowledge on NGINX configuration files
  • Learning the basics of SQL and how to send queries using the CLI client
  • Learning how to setup a working website from scratch :
    • Generating a SSL certificate
    • Setting up the route to proxy_pass requests to the CGI/FastCGI
    • Creating a Database with access and running a DB Client (mysqld)
  • Adding a monitoring system to a docker stack with node_exporter, Prometheus and Grafana
  • Learning the basis of Javascript for frontend and backend (nodeJS/Express) web development

Challenges faced

  • Working with the differences between the MACOS and Linux version of Docker
  • Recreating my own version of the official images of NGINX, MariaDB, PHP-FPM was time consuming (but greatly increased my ease with DockerFiles along with my knowledge of how thoses services work). Same goes for the Monitoring stack (Grafana/Prometheus/node_exporter)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp