-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2,638 changed files
with
1,226,659 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
all: | ||
cd srcs && docker-compose up --build -d | ||
|
||
clean: | ||
cd srcs && docker-compose down --rmi all -v | ||
fclean: clean | ||
docker images -qa | xargs --no-run-if-empty docker rmi -f | ||
re: fclean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,104 @@ | ||
# inception | ||
# inception | ||
|
||
1337 project, setup of a small infrastructure with docker-compose. Services include an nginx, Wordpress and a MariaDB database. When you run **make** the scripts build the custom Docker images for each of those, before deploying and establishing a connection between all of them with a custom yaml file. | ||
|
||
## Notes | ||
|
||
### Docker vs Docker-compose | ||
Docker is simply a software that allow users to run lightweight virtual machines. | ||
Docker-compose is a Yaml file consisting of all the details regarding various services, netwroks | ||
and volumes that are needed for setting up the application. | ||
It is used for creating multiple containers, host them and establish communication | ||
between them. | ||
|
||
### Container terminology | ||
|
||
Container is two different things. Like a normal Linux program, | ||
containers have two states -rest and running. | ||
When at rest, a container is a set of files that is saved on the desk | ||
(container image). | ||
Once running, containers are just a linux process. | ||
|
||
Docker is a container engines that takes a container image | ||
and turn it into a container(running process). | ||
|
||
Container Image is a file which can be pulled down from a | ||
registry server(DockerHub) or created from scratch. It contains all dependecies | ||
and configuration to run a program. | ||
|
||
|
||
Registry server is a fancy file server that is used to | ||
store docker repositories.When a docker daemon does not have a locally cached | ||
copy of a repo, it will automatically pull it from a registry server. | ||
|
||
### Basic commands of docker && docker-compose | ||
|
||
``` | ||
docker container run #starts a new container | ||
docker container start #start an existing stopped one | ||
docker logs #shows logs for a specific container | ||
docker container rm #remove one or more containers | ||
docker list #list running processes in specific container | ||
ps aux #show all runing processes | ||
docker-compose up #it builds the images if they are not located locally and starts the containers | ||
docker-compose ps #list all the containers in the current docker-compose file. | ||
docker-compose down #it stops all the services and cleans up the containers, netwroks and images. | ||
``` | ||
### Docker network and why it is important | ||
|
||
To make containers connect to each other and share files and | ||
ressources we should create a network.There are various kinds of netwrok drivers : bridge, overlay. | ||
Bridge driver is limited to local. | ||
|
||
By dfault, the container is assigned an IP address for every docker netwrok it connects to. | ||
The IP address is assigned from the pool; assigned to the netwrok. | ||
The docker daemon acts as a DHCP server for each container. | ||
Each network has a default subnet mask and a gateway. | ||
Whenever a containr is restarted a new IP adress is assigned to the container. | ||
|
||
Docker secures the network by managing rules to block connectivity between | ||
different docker networks and that's why we need to expose ports for external access. | ||
|
||
### php FastGCI Process Manager | ||
PHP-FPM is an acronym for FASTCGI process Manager.It's an interface allowing communication between nginx and php. | ||
|
||
**To connect Nginx to PHP-FPM unix or TCP/IP socket** | ||
Nginx sends FastCGI requests to PHP-FPM. | ||
to make that happens, PHP-FPM can either listen on a TCP/IP socket or unix domain. | ||
using the fastcgi_pass directive. | ||
|
||
Unix Domain are meant for inter-process communication that allow data exchange between | ||
processes running on the same operating system. | ||
TCP/IP allow connection between PHP-FPM and NGINX even if they are running on different | ||
systems. | ||
|
||
**To configure PHP-FPM to listen address** | ||
modify www.conf to define the address he gonna listens through. | ||
configure nginx to work with php-fpm app server via the same address using fastcgi_pass | ||
configuration parameter. | ||
|
||
### Docker volume | ||
|
||
Let's suppose that we have a database container and the container has a virtual | ||
file system where the data is usually stored. But, when I want to remove or | ||
restart the container the data in this virtual file system is removed and gone. | ||
|
||
Volume is the preferred mechanism for persisting data generated by and used by Docker containers. | ||
It is a folder in phisycal host file system which is mounted into the | ||
virtual file system of docker. | ||
|
||
## Useful links | ||
[Docker guide](https://www.educative.io/blog/docker-kubernetes-beginners-guide) | ||
|
||
[Docker-compose tutorial](https://www.educative.io/blog/docker-compose-tutorial) | ||
|
||
[Connect nginx to php](https://www.tecmint.com/connect-nginx-to-php-fpm/) | ||
|
||
[Port binding](https://betterprogramming.pub/how-does-docker-port-binding-work-b089f23ca4c8) | ||
|
||
[Configure remote access to MariaDB](https://websiteforstudents.com/configure-remote-access-mysql-mariadb-databases/) | ||
|
||
[Docker-compose volume and networks](https://faun.pub/how-to-use-docker-compose-volumes-networks-and-more-24f82169c077) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
DOMAINE_NAME=framdani.42.fr | ||
|
||
ROOT_PASSWORD=root1framdani | ||
DB_USER=framdani@user | ||
DB_PASSWORD=framdani1234 | ||
DB_NAME=finception | ||
DB_HOST=mariadb | ||
|
||
USER_WORDPRESS=framdani@student.1337.ma | ||
PASSWORD_WORDPRESS=1337@Bg! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
version: "3" | ||
|
||
services: | ||
mariadb: | ||
build: ./requirements/mariadb | ||
container_name: mariadb | ||
networks: | ||
- myapp-network | ||
volumes: | ||
- database:/var/lib/mysql/ | ||
env_file: | ||
- .env | ||
restart: unless-stopped | ||
nginx: | ||
build: ./requirements/nginx | ||
container_name: nginx | ||
depends_on: | ||
- wordpress | ||
ports: | ||
- 443:443 | ||
networks: | ||
- myapp-network | ||
volumes: | ||
- html:/var/www/html | ||
restart: unless-stopped | ||
wordpress: | ||
build: ./requirements/wordpress | ||
container_name: wordpress | ||
depends_on: | ||
- mariadb | ||
networks: | ||
- myapp-network | ||
volumes: | ||
- html:/var/www/html | ||
env_file: | ||
- .env | ||
restart: unless-stopped | ||
|
||
networks: | ||
myapp-network: | ||
driver: bridge | ||
volumes: | ||
html : | ||
driver: local | ||
driver_opts: | ||
type: none | ||
o: bind | ||
device : /home/framdani/data/html | ||
database : | ||
driver: local | ||
driver_opts: | ||
type: none | ||
o: bind | ||
device : /home/framdani/data/DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#Mariadb is community-developed relational database management system | ||
|
||
FROM debian:buster | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y mariadb-server | ||
|
||
COPY tools / | ||
|
||
COPY conf / | ||
|
||
CMD ["sh" , "script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[mysqld] | ||
port = 3306 | ||
bind_address = 0.0.0.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!bin/bash | ||
|
||
cp my.cnf /etc/mysql/ | ||
|
||
if [ -d /var/lib/mysql/finception ] | ||
then | ||
echo "already exist !" | ||
else | ||
service mysql start | ||
mysql -u root -e "CREATE USER '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASSWORD}';" | ||
mysql -u root -e "CREATE DATABASE ${DB_NAME};" | ||
mysql -u root -e "USE ${DB_NAME}; GRANT ALL PRIVILEGES ON * TO '${DB_USER}'@'%'; " | ||
mysql -u root -e "FLUSH PRIVILEGES;" | ||
mysqladmin --user=root password ${ROOT_PASSWORD} | ||
mysql -u root --password=${ROOT_PASSWORD} ${DB_NAME} < /db.sql | ||
service mysql stop | ||
fi | ||
mysqld_safe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM debian:buster | ||
|
||
RUN apt-get upgrade | ||
RUN apt-get update | ||
|
||
|
||
RUN apt-get install -y nginx vim | ||
|
||
|
||
COPY ./conf/default /etc/nginx/sites-available/default | ||
COPY ./tools/nginx-selfsigned.key /etc/ssl/ | ||
COPY ./tools/nginx-selfsigned.crt /etc/ssl/ | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
server { | ||
listen 443 ssl default_server; | ||
listen [::]:443 ssl default_server; | ||
|
||
ssl_certificate /etc/ssl/nginx-selfsigned.crt; | ||
ssl_certificate_key /etc/ssl/nginx-selfsigned.key; | ||
ssl_protocols TLSv1.2 TLSv1.3; | ||
root /var/www/html; | ||
|
||
index index.php index.html; | ||
|
||
location / { | ||
try_files $uri $uri/ =404; | ||
} | ||
location ~ .php$ { | ||
try_files $uri =404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass wordpress:9000; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-----BEG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pyIDFyWUp7TX+E5xAyisjaqCyMXFIir3VJeLG5nCiWoY | ||
HEP59dhrC9pSau/gJZ+IemekqgUyjtpvnv/fOIuC1BzxzMP8lqxV/puYLXpknULA | ||
L9jQsck0gUlUU0b+SN+4Yzf571Ng/gEc3tj0+dkm6KBMzhRrCyc2t8Mf/Vd/Rz5q | ||
Obe0FQBSWl3ci/a8Ejo= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDSMJ72f6UV5d6W | ||
U7Z92j7Xc0Xgrh4OaWtWmvvmnavpF/Po7Yv3mfIUFK5p1WNqQlTiVNDulvW2mcCW | ||
t0dW+FcxM4oviiSfPPATVhoXDdbnXkRlhybdWMer2SyE/lRQU9Wu2TQQ+CALAzwp | ||
/qTegkgjdm/QnHkvB6CtbyCYVNa8xi7Rkx5thUnCiLx7sz50lWHhZ4jJC6aMx5AU | ||
9Ie+SEsGChXDjkpiagraWDcHrqf6Jx9lWkn4vn7fCR0NGnq6rUGyEEhPz/MT+jJQ | ||
PxHKgUNZf3VmZ9i2qPpbBgYWKBmEfXgB+N6/1D7KKgn6MXM55cfgxoVloL7+I1Yz | ||
xzNeunRzAgMBAAECggEATOsMESrPD/9qAFssKkwmuRNvG/S7/QwpAq1+x3slwQxJ | ||
7xCXKwoEI8MZvJMhaW5Sv+zH9Lf7vVHwv3bcvX/t8Ixq4lDMbBWRyZG1xIAFB/Bg | ||
WUMnPtNRZpr4BsdHtYmoZe8IdblHiKArcTbFwMOugIPEEXRhiItjCnTjWbuaRcQa | ||
7NGepD0mkxbvKzP2eTWWpY7H9bTtkMzb1GHnsaXTprkE0ybzRtm3dB0c+7gMNU3Q | ||
165rG1saqr98BtIJc5iAwQMBygxOBnt9xx1QUuTRG3nw4wtV9CSyahiPhW5Oo/NY | ||
6bgwM6lUQGycRRJhCbKm+3pVSiQzkpuNRuV0scj4CQKBgQDrOqrwzsAqZ4JYHAht | ||
EHJJB3YkwvBbHTHPgINjoo432wjC8BS8trpe8sb0IdcDmGcRc+731whGtcMOvzBo | ||
hMKeWTd4PkfV2EVIZ+P8T+VnN68evs2GgoO6afYwjiSdNgPdOjVI7U9GgIzyZybc | ||
tjfeJQSmieRDApaKTebTDNIEVQKBgQDkv/GLlkES18IxEmfiIGMZ7YlHijDSWbAG | ||
hoaNf+5ScF6sq1IeRA+WPNk0Xzq13Mqx8n6ZykmhVgH6YguV1qON/jxnypb7jDIO | ||
Ob7tCvG5LnkSo4Bkt+a21VoRF/UYkFXLRcskuEbIYl5fo7Uju8wMvlZMVAIay7pl | ||
4+eTNkwdpwKBgQCTQLy11peRdA6ynYngzITelp8s0COqxhHide7KNn6VFLbdYXF5 | ||
2WG+AnjtZym0hHkxAcQ8vg3eRfZ/iswBAerbObpxuXs6sRJeCzs7PcC75q3nr0X1 | ||
yEoyLhcBulnNWHz+xmuI5ZXU6rBRJqW7UQ6UL9RDdNrB4CLhHXc78zCdqQKBgFHS | ||
XoIBgtFMn8eRv9rgntIdZydRxNjY/9+1qtdeVU7jptm4hi0RR0oEBeV30rZOfapd | ||
BO/ZrbCp5Rc8jsxP9DzMHas6ifr8UMNJ4INFkOUePGxwU3KzXTE063yFx0O8DRQi | ||
qOE/kQIIPZ2UHyzi9b/xLUksG3yeNtRPSvwbReqtAoGAILog+WIL8PuFCaFB1Ycb | ||
rp/jD06e1sCtpyX2iZ9oTvxHF8Gfs0t2Qi0vw3gapXPd4ZilbKVJRkoAi16yEAEm | ||
lpPCo8Z4ltXjQWBk/hKXz90G370zAMTP3uVPXzPvHhnIw73sWQ4rzFzMWUv+s8sM | ||
tuYByye210aYKrq3LQqI0Q8= | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM debian:buster | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y php7.3-fpm php7.3-mysql | ||
|
||
COPY tools / | ||
|
||
COPY config / | ||
|
||
CMD ["sh", "script.sh"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Front to the WordPress application. This file doesn't do anything, but loads | ||
* wp-blog-header.php which does and tells WordPress to load the theme. | ||
* | ||
* @package WordPress | ||
*/ | ||
|
||
/** | ||
* Tells WordPress to load the WordPress theme and output it. | ||
* | ||
* @var bool | ||
*/ | ||
define( 'WP_USE_THEMES', true ); | ||
|
||
/** Loads the WordPress Environment and Template */ | ||
require __DIR__ . '/wp-blog-header.php'; |
Oops, something went wrong.