├── srcs ├── .dockerignore ├── requirements │ ├── wordpress │ │ ├── conf │ │ │ └── www.conf │ │ ├── script │ │ │ └── configure.sh │ │ └── Dockerfile │ ├── mariadb │ │ ├── Dockerfile │ │ └── script │ │ │ └── configure.sh │ └── nginx │ │ ├── Dockerfile │ │ └── conf │ │ └── nginx.conf ├── .env └── docker-compose.yml ├── inception.png ├── .gitignore ├── .github └── workflows │ ├── macos.yml │ └── ubuntu.yml ├── README.md └── Makefile /srcs/.dockerignore: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /inception.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malatini42/inception/HEAD/inception.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ./srcs/requirements/nginx/log/* 2 | ./srcs/requirements/mariadb/data 3 | ./srcs/requirements/wordpress/website 4 | -------------------------------------------------------------------------------- /srcs/requirements/wordpress/conf/www.conf: -------------------------------------------------------------------------------- 1 | [www] 2 | user = nginx 3 | group = nginx 4 | listen = 9000 5 | pm = dynamic 6 | pm.max_children = 5 7 | pm.start_servers = 2 8 | pm.min_spare_servers = 1 9 | pm.max_spare_servers = 3 -------------------------------------------------------------------------------- /srcs/requirements/mariadb/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.13 2 | 3 | RUN apk update && apk upgrade && apk add --no-cache \ 4 | mariadb \ 5 | mariadb-client 6 | 7 | COPY script/configure.sh /tmp/configure.sh 8 | 9 | ENTRYPOINT ["sh", "/tmp/configure.sh"] -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: MacOS CI 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: macos-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install dependencies 18 | run: echo "test it on your personnal machine" 19 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu CI 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Install dependencies 18 | run: echo "test it on your personnal machine" 19 | -------------------------------------------------------------------------------- /srcs/.env: -------------------------------------------------------------------------------- 1 | MYSQL_HOST=mariadb 2 | MYSQL_ROOT_PWD=user 3 | 4 | WP_DATABASE_NAME=wordpress 5 | WP_DATABASE_USR=malatini 6 | WP_DATABASE_PWD=password 7 | 8 | DOMAIN_NAME=localhost 9 | 10 | WP_TITLE=Inception 11 | WP_ADMIN_USR=malatini 12 | WP_ADMIN_PWD=password 13 | WP_ADMIN_EMAIL=malatini@student.42.fr 14 | 15 | WP_USR=malatinibis 16 | WP_PWD=password 17 | WP_EMAIL=malatini+bis@student.42.fr -------------------------------------------------------------------------------- /srcs/requirements/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.13 2 | 3 | RUN apk update && apk upgrade && apk add --no-cache \ 4 | nginx openssl 5 | 6 | RUN mkdir /etc/nginx/ssl 7 | 8 | RUN openssl req -newkey rsa:4096 -x509 -sha256 -days 365 -nodes \ 9 | -out /etc/nginx/ssl/malatini.pem \ 10 | -keyout /etc/nginx/ssl/malatini.key \ 11 | -subj "/C=IT/ST=Paris/L=Paris/O=42 School/OU=rmalatini/CN=matini/" 12 | 13 | RUN mkdir -p /run/nginx 14 | 15 | COPY conf/nginx.conf /etc/nginx/conf.d/default.conf 16 | 17 | ENTRYPOINT ["nginx", "-g", "daemon off;"] -------------------------------------------------------------------------------- /srcs/requirements/wordpress/script/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while ! mariadb -h$MYSQL_HOST -u$WP_DATABASE_USR -p$WP_DATABASE_PWD $WP_DATABASE_NAME &>/dev/null; do 4 | sleep 3 5 | done 6 | 7 | if [ ! -f "/var/www/html/index.html" ]; then 8 | wp core download --locale=fr_FR 9 | wp config create --dbname=$WP_DATABASE_NAME --dbuser=$WP_DATABASE_USR --dbpass=$WP_DATABASE_PWD --dbhost=$MYSQL_HOST --dbcharset="utf8" --dbcollate="utf8_general_ci" 10 | wp core install --url=$DOMAIN_NAME --title=$WP_TITLE --admin_user=$WP_ADMIN_USR --admin_password=$WP_ADMIN_PWD --admin_email=$WP_ADMIN_EMAIL 11 | wp user create $WP_USR $WP_EMAIL --role=author --user_pass=$WP_PWD 12 | wp theme install inspiro --activate 13 | fi 14 | php-fpm7 --nodaemonize -------------------------------------------------------------------------------- /srcs/requirements/wordpress/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.13 2 | 3 | RUN apk update 4 | 5 | RUN apk add --no-cache --quiet --update curl bash vim 6 | 7 | RUN apk add --no-cache --quiet --update mariadb-client 8 | 9 | RUN apk add --no-cache --quiet --update php7 php-phar \ 10 | php-json php-curl php-fpm php-mysqli php-iconv 11 | 12 | RUN adduser -S nginx && addgroup -S nginx 13 | 14 | COPY conf/www.conf /etc/php7/php-fpm.d/www.conf 15 | 16 | RUN wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 17 | 18 | RUN chmod +x wp-cli.phar 19 | 20 | RUN cp wp-cli.phar /usr/bin/wp 21 | 22 | WORKDIR /var/www/html 23 | 24 | COPY script/configure.sh /tmp/configure.sh 25 | 26 | ENTRYPOINT [ "sh", "/tmp/configure.sh" ] 27 | 28 | 29 | -------------------------------------------------------------------------------- /srcs/requirements/nginx/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | server { 3 | listen 80; 4 | server_name inception; 5 | return 301 https://$host$request_uri; 6 | } 7 | 8 | server { 9 | listen 443 ssl; 10 | 11 | server_name malatini.42.fr; 12 | 13 | ssl_certificate /etc/nginx/ssl/malatini.pem; 14 | ssl_certificate_key /etc/nginx/ssl/malatini.key; 15 | ssl_protocols TLSv1.2 TLSv1.3; 16 | 17 | root /var/www/html; 18 | 19 | index index.php index.html index.htm; 20 | 21 | location / { 22 | try_files $uri $uri/ =404; 23 | } 24 | 25 | location ~ \.php$ { 26 | fastcgi_pass wordpress:9000; 27 | fastcgi_index index.php; 28 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 29 | include fastcgi_params; 30 | } 31 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # inception 📚 2 | 3 | inception - 2022 (Common Core). 4 | 5 | - Actual Status : validated (07/01/2022) 6 | 7 | I updated the project since its validation. 8 | The version is currently working on my own macbook without any VM. 9 | 10 | [Watch](https://youtu.be/wGJFx-H6KX8) 11 | 12 | inception 13 | comment 14 | images 15 | 16 | Thanks @raccoman for your great example repository. 17 | ![Alt text](/inception.png?raw=true 'Inception') 18 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = inception 2 | 3 | DOCKER_COMPOSE = docker compose -f ./srcs/docker-compose.yml 4 | 5 | DOCKER = docker 6 | 7 | all: macos 8 | ${DOCKER_COMPOSE} build 9 | ${DOCKER_COMPOSE} up -d 10 | 11 | macos: 12 | echo "127.0.0.1 malatini.42.fr" >> /etc/hosts 13 | echo "127.0.0.1 www.malatini.42.fr" >> /etc/hosts 14 | 15 | ls: 16 | ${DOCKER} ps -a 17 | 18 | build: 19 | ${DOCKER_COMPOSE} build 20 | 21 | up: 22 | ${DOCKER_COMPOSE} up -d 23 | 24 | down: 25 | ${DOCKER_COMPOSE} down 26 | 27 | pause: 28 | ${DOCKER_COMPOSE} pause 29 | 30 | unpause: 31 | ${DOCKER_COMPOSE} unpause 32 | 33 | clean: down 34 | rm -rf ~/Documents/inception/srcs/requirements/nginx/log/* 35 | rm -rf ~/Documents/inception/srcs/requirements/mariadb/data 36 | rm -rf ~/Documents/inception/srcs/requirements/wordpress/website 37 | ${DOCKER_COMPOSE} down -v --rmi all --remove-orphans 38 | 39 | fclean: clean 40 | ${DOCKER} system prune -f 41 | 42 | re: fclean all 43 | 44 | .PHONY: linux stop clean prune all build up -------------------------------------------------------------------------------- /srcs/requirements/mariadb/script/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -d "/run/mysqld" ]; then 4 | mkdir -p /run/mysqld 5 | chown -R mysql:mysql /run/mysqld 6 | fi 7 | 8 | if [ ! -d "/var/lib/mysql/mysql" ]; then 9 | 10 | chown -R mysql:mysql /var/lib/mysql 11 | 12 | # init database 13 | mysql_install_db --basedir=/usr --datadir=/var/lib/mysql --user=mysql --rpm > /dev/null 14 | 15 | tfile=`mktemp` 16 | if [ ! -f "$tfile" ]; then 17 | return 1 18 | fi 19 | cat << EOF > $tfile 20 | USE mysql; 21 | FLUSH PRIVILEGES; 22 | 23 | DELETE FROM mysql.user WHERE User=''; 24 | DROP DATABASE test; 25 | DELETE FROM mysql.db WHERE Db='test'; 26 | DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); 27 | 28 | ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQL_ROOT_PWD'; 29 | 30 | CREATE DATABASE $WP_DATABASE_NAME CHARACTER SET utf8 COLLATE utf8_general_ci; 31 | CREATE USER '$WP_DATABASE_USR'@'%' IDENTIFIED by '$WP_DATABASE_PWD'; 32 | GRANT ALL PRIVILEGES ON $WP_DATABASE_NAME.* TO '$WP_DATABASE_USR'@'%'; 33 | 34 | FLUSH PRIVILEGES; 35 | EOF 36 | /usr/bin/mysqld --user=mysql --bootstrap < $tfile 37 | fi 38 | 39 | sed -i "s|skip-networking|# skip-networking|g" /etc/my.cnf.d/mariadb-server.cnf 40 | sed -i "s|.*bind-address\s*=.*|bind-address=0.0.0.0|g" /etc/my.cnf.d/mariadb-server.cnf 41 | 42 | exec /usr/bin/mysqld --user=mysql --console -------------------------------------------------------------------------------- /srcs/docker-compose.yml: -------------------------------------------------------------------------------- 1 | networks: 2 | backend: 3 | 4 | services: 5 | nginx: 6 | container_name: nginx 7 | build: ./requirements/nginx 8 | volumes: 9 | - ~/Documents/inception/srcs/requirements/nginx/log:/var/log/nginx 10 | - ~/Documents/inception/srcs/requirements/wordpress/website:/var/www/html 11 | networks: 12 | - backend 13 | ports: 14 | - '443:443' 15 | expose: 16 | - '443' 17 | depends_on: 18 | - wordpress 19 | restart: always 20 | 21 | wordpress: 22 | container_name: wordpress 23 | depends_on: 24 | - mariadb 25 | build: ./requirements/wordpress 26 | volumes: 27 | - ~/Documents/inception/srcs/requirements/wordpress/website:/var/www/html 28 | networks: 29 | - backend 30 | environment: 31 | MYSQL_HOST: ${MYSQL_HOST} 32 | WP_DATABASE_NAME: ${WP_DATABASE_NAME} 33 | WP_DATABASE_USR: ${WP_DATABASE_USR} 34 | WP_DATABASE_PWD: ${WP_DATABASE_PWD} 35 | DOMAIN_NAME: ${DOMAIN_NAME} 36 | WP_TITLE: ${WP_TITLE} 37 | WP_ADMIN_USR: ${WP_ADMIN_USR} 38 | WP_ADMIN_PWD: ${WP_ADMIN_PWD} 39 | WP_ADMIN_EMAIL: ${WP_ADMIN_EMAIL} 40 | WP_USR: ${WP_USR} 41 | WP_PWD: ${WP_PWD} 42 | WP_EMAIL: ${WP_EMAIL} 43 | restart: always 44 | 45 | mariadb: 46 | container_name: mariadb 47 | build: ./requirements/mariadb 48 | volumes: 49 | - ~/Documents/inception/srcs/requirements/mariadb/data:/var/lib/mysql 50 | networks: 51 | - backend 52 | environment: 53 | MYSQL_ROOT_PWD: ${MYSQL_ROOT_PWD} 54 | WP_DATABASE_NAME: ${WP_DATABASE_NAME} 55 | WP_DATABASE_USR: ${WP_DATABASE_USR} 56 | WP_DATABASE_PWD: ${WP_DATABASE_PWD} 57 | restart: always 58 | --------------------------------------------------------------------------------