Skip to content

ferri17/inception

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repo stars GitHub top language GitHub code size in bytes GitHub last commit (by committer) Linux compatibility

Inception 42 school project

This project consists in setting up a docker infrastructure composed of 3 services, a local wordpress installation, a Mysql(mariaDB) database to support the website, and to finish an nginx server to manage requests to the website.

About The Project

Screenshot 2024-03-20 at 01 05 55

The system follows these rules:

  • A Docker container contains NGINX with TLSv1.3.
  • A Docker container contains WordPress + php-fpm.
  • A Docker container contains MariaDB.
  • 2 volumes: 1 stores website files (wordpress), the other one stores the database(mariaDB).
  • A Docker network comunicates all the containers between each other.
  • The system can only be accessed through port 443 (https) on nginx container.

Getting Started

In order to run the program first clone the repository:

git clone git@github.com:ferri17/inception.git

Open the folder:

cd inception/

Start the services:

make

Once the services are up and running, you can access the website:

https://localhost:443

When you are done you can close the services:

make clean

Makefile

I created a makefile to quickly build and clean the setup. It allows to build(make), stop the services(make down), and fully clean - docker + local storage - (make clean).

GREEN=\033[1;32m
RED=\033[1;31m
BLUE=\033[1;34m
END=\033[0m

DOCKER_COMPOSE_FILE = srcs/docker-compose.yml

all:
	@echo "$(GREEN)Building and starting all containers: $(END)"
	mkdir -p /home/$(USER)/data/wordpress
	mkdir -p /home/$(USER)/data/mariadb
	docker compose -f $(DOCKER_COMPOSE_FILE) up --detach --build

down:
	docker compose -f $(DOCKER_COMPOSE_FILE) down
clean:
	@if [ ! -z "$$(docker ps -aq)" ]; then \
		docker stop $$(docker ps -aq); \
		docker rm $$(docker ps -aq); \
	fi
	@if [ ! -z "$$(docker images -aq)" ]; then \
		docker rmi $$(docker images -aq); \
	fi	
	@if [ ! -z "$$(docker volume ls -q)" ]; then \
		docker volume rm $$(docker volume ls -q); \
	fi
	@if [ ! -z "$$(docker network ls -q --filter type=custom)" ]; then \
		docker network rm $$(docker network ls -q --filter type=custom); \
	fi
	rm -rf /home/$(USER)/data/wordpress
	rm -rf /home/$(USER)/data/mariadb
	@echo "$(GREEN)Deleted all docker containers, volumes, networks, and images succesfully$(END)"

re: clean all

.PHONY: all down clean

docker-compose.yml

The only point of access to this infrastructure is through nginx service on port 443. The containers communicate through a internal network called 'fbosch_network'.

The services make use of 2 volumes, the purpose of the volumes is to have permanent storage in the host machine and not lose all changes after closing the services.

  • wordpress_data: nginx and wordpress bind '/var/www/html' in their own containers to '/home/${USER}/data/wordpress' in the host machine, this way nginx can access all files generated by wordpress.
  • mariadb_data: mariadb binds '/var/lib/mysql' to '/home/${USER}/data/mariadb', storing all changes made on the database in the host.
services:

  nginx:
    depends_on:
      - wordpress
    container_name: nginx
    build: requirements/nginx/
    image: nginx
    volumes:
      - wordpress_data:/var/www/html
    networks:
      - fbosch_network
    ports:
      - "443:443"
    restart: always

  wordpress:
    depends_on:
      - mariadb
    container_name: wordpress
    build: requirements/wordpress
    image: wordpress
    volumes:
      - wordpress_data:/var/www/html
    networks:
      - fbosch_network
    env_file:
      - .env
    restart: always

  mariadb:
    container_name: mariadb
    build: requirements/mariadb
    image: mariadb
    volumes:
      - mariadb_data:/var/lib/mysql
    networks:
      - fbosch_network
    env_file:
      - .env
    restart: always


volumes:

  wordpress_data:
    driver: local
    driver_opts:
      device: "/home/${USER}/data/wordpress"
      o: bind
      type: none
  
  mariadb_data:
    driver: local
    driver_opts:
      device: "/home/${USER}/data/mariadb"
      o: bind
      type: none


networks:
  fbosch_network:
    name: fbosch_network
    driver: bridge

About

Docker infrastructure consisting of 3 connected containers, Wordpress, MariaDB and NGINX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors