mirror of
https://github.com/Ladebeze66/Inception.git
synced 2025-12-15 21:57:09 +01:00
ff
This commit is contained in:
parent
6bbba835b5
commit
d80f2f7417
@ -6,6 +6,8 @@ HOSTNAME=fgras-ca.42.fr
|
|||||||
HOSTS_FILE=/etc/hosts
|
HOSTS_FILE=/etc/hosts
|
||||||
VOLUME_DIR_MYSQL = /home/$(USER)/data/mysql
|
VOLUME_DIR_MYSQL = /home/$(USER)/data/mysql
|
||||||
VOLUME_DIR_HTML = /home/$(USER)/data/html
|
VOLUME_DIR_HTML = /home/$(USER)/data/html
|
||||||
|
VOLUMES_DIR = /home/$(USER)/data
|
||||||
|
DOCKER_COMPOSE_FILE = ./srcs/docker-compose.yml
|
||||||
|
|
||||||
all: sudo-validate setup-hosts create-volumes start-docker
|
all: sudo-validate setup-hosts create-volumes start-docker
|
||||||
|
|
||||||
@ -15,7 +17,7 @@ sudo-validate:
|
|||||||
|
|
||||||
down:
|
down:
|
||||||
@echo "Stopping and removing all Docker containers..."
|
@echo "Stopping and removing all Docker containers..."
|
||||||
@docker-compose -f /home/$(USER)/data/scrs/docker-compose.yml down
|
@docker-compose -f $(DOCKER_COMPOSE_FILE) down
|
||||||
|
|
||||||
re: down all
|
re: down all
|
||||||
|
|
||||||
@ -38,9 +40,7 @@ clean: down
|
|||||||
|
|
||||||
@docker system prune -a --force --volumes
|
@docker system prune -a --force --volumes
|
||||||
@echo "Removing MySQL and HTML data directories..."
|
@echo "Removing MySQL and HTML data directories..."
|
||||||
@sudo chmod -R 777 $(VOLUME_DIR_MYSQL)
|
@sudo rm -rf $(VOLUMES_DIR)
|
||||||
@sudo chmod -R 777 $(VOLUME_DIR_HTML)
|
|
||||||
@sudo rm -rf $(VOLUME_DIR_MYSQL) $(VOLUME_DIR_HTML)
|
|
||||||
|
|
||||||
setup-hosts:
|
setup-hosts:
|
||||||
@echo "Configuring /etc/hosts..."
|
@echo "Configuring /etc/hosts..."
|
||||||
@ -54,10 +54,6 @@ create-volumes:
|
|||||||
|
|
||||||
start-docker:
|
start-docker:
|
||||||
@echo "Starting Docker Compose in detached mode..."
|
@echo "Starting Docker Compose in detached mode..."
|
||||||
@docker-compose -f /home/$(USER)/data/scrs/docker-compose.yml up --build
|
@docker-compose -f $(DOCKER_COMPOSE_FILE) up -d --build
|
||||||
|
|
||||||
.PHONY: all re down clean setup-hosts create-volumes start-docker sudo-validate
|
.PHONY: all re down clean setup-hosts create-volumes start-docker sudo-validate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
DOMAIN_NAME=
|
|
||||||
CERTS_=/etc/nginx/ssl/inception.key
|
|
||||||
MYSQL_HOSTNAME=
|
|
||||||
MYSQL_DATABASE=
|
|
||||||
MYSQL_USER=
|
|
||||||
MYSQL_PASSWORD=
|
|
||||||
MYSQL_ROOT_PASSWORD=
|
|
||||||
WP_TITLE=
|
|
||||||
WP_ADMIN_USR=
|
|
||||||
WP_ADMIN_PWD=
|
|
||||||
WP_ADMIN_EMAIL=
|
|
||||||
WP_USR=
|
|
||||||
WP_EMAIL=
|
|
||||||
WP_PWD=
|
|
||||||
ftp_user=
|
|
||||||
ftp_pwd=
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
[mysql]
|
|
||||||
default-character-set=utf8
|
|
||||||
|
|
||||||
[mysqld]
|
|
||||||
datadir = /var/lib/mysql
|
|
||||||
#socket = /run/mysqld/mysqld.sock
|
|
||||||
bind_address=*
|
|
||||||
port = 3306
|
|
||||||
user = mysql
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Démarrer le service MariaDB
|
|
||||||
service mysql start
|
|
||||||
# Remplacer les variables dans le fichier SQL
|
|
||||||
envsubst < /docker-entrypoint-initdb.d/init_db_template.sql > /docker-entrypoint-initdb.d/init_db.sql
|
|
||||||
# Exécuter le script SQL d'initialisation
|
|
||||||
mysql -u root -p"${MYSQL_ROOT_PASSWORD}" < /docker-entrypoint-initdb.d/init_db.sql
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Échec de l'exécution du script SQL"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "=== Script SQL exécuté avec succès ==="
|
|
||||||
|
|
||||||
# Fonction de surveillance pour garder le conteneur en cours d'exécution
|
|
||||||
while true; do
|
|
||||||
sleep 60
|
|
||||||
if ! pgrep mysqld > /dev/null; then
|
|
||||||
echo "Le service MySQL s'est arrêté, redémarrage..."
|
|
||||||
service mysql restart
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE};
|
|
||||||
CREATE USER IF NOT EXISTS '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';
|
|
||||||
GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'%';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
|
|
||||||
CREATE USER IF NOT EXISTS '${MYSQL_ADMIN_USER}'@'%' IDENTIFIED BY '${MYSQL_ADMIN_PASSWORD}';
|
|
||||||
GRANT ALL PRIVILEGES ON *.* TO '${MYSQL_ADMIN_USER}'@'%' WITH GRANT OPTION;
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
user www-data;
|
|
||||||
worker_processes auto;
|
|
||||||
pid /run/nginx.pid;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
tcp_nodelay on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
types_hash_max_size 2048;
|
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
error_log /var/log/nginx/error.log;
|
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_disable "msie6";
|
|
||||||
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
|
||||||
include /etc/nginx/sites-enabled/*;
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
ssl_certificate /etc/nginx/ssl/inception.crt;
|
|
||||||
ssl_certificate_key /etc/nginx/ssl/inception.key;
|
|
||||||
|
|
||||||
root /var/www/html;
|
|
||||||
server_name fgras-ca.42.fr;
|
|
||||||
index index.php index.html index.htm;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
include snippets/fastcgi-php.conf;
|
|
||||||
fastcgi_pass wordpress:9000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
16
srcs/.env
Normal file
16
srcs/.env
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
DOMAIN_NAME=fgras-ca.42.fr
|
||||||
|
CERTS_=/etc/nginx/ssl/inception.key
|
||||||
|
MYSQL_HOSTNAME=mariadb
|
||||||
|
MYSQL_DATABASE=wordpress
|
||||||
|
MYSQL_USER=fgras
|
||||||
|
MYSQL_PASSWORD=1234
|
||||||
|
MYSQL_ROOT_PASSWORD=5678
|
||||||
|
WP_TITLE=FernandGrasCalvet
|
||||||
|
WP_ADMIN_USR=fgras-ca
|
||||||
|
WP_ADMIN_PWD=1234
|
||||||
|
WP_ADMIN_EMAIL=fgras.ca@gmail.com
|
||||||
|
WP_USR=fgras
|
||||||
|
WP_EMAIL=fgras.ca@42.com
|
||||||
|
WP_PWD=123
|
||||||
|
ftp_user=Dino
|
||||||
|
ftp_pwd=gg66!
|
||||||
@ -22,6 +22,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./requirements/wordpress
|
context: ./requirements/wordpress
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- mariadb
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
expose:
|
expose:
|
||||||
@ -1,4 +1,7 @@
|
|||||||
FROM debian:buster
|
FROM debian:bullseye
|
||||||
|
|
||||||
|
# Exposer le port 3306
|
||||||
|
EXPOSE 3306
|
||||||
|
|
||||||
# Installer les paquets nécessaires
|
# Installer les paquets nécessaires
|
||||||
RUN apt update -y && apt upgrade -y && \
|
RUN apt update -y && apt upgrade -y && \
|
||||||
@ -10,18 +13,13 @@ RUN mkdir -p /run/mysqld /var/www && \
|
|||||||
chown mysql:mysql /run/mysqld
|
chown mysql:mysql /run/mysqld
|
||||||
|
|
||||||
# Copier les fichiers de configuration
|
# Copier les fichiers de configuration
|
||||||
COPY ./conf/50-server.cnf /etc/mysql/mariadb.conf.d/
|
COPY ./conf/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||||
COPY ./tools/init_db_template.sql /docker-entrypoint-initdb.d/init_db_template.sql
|
|
||||||
COPY ./tools/entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY ./tools/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
# Assurer les permissions correctes pour le script et les fichiers SQL
|
# Assurer les permissions correctes pour le script et les fichiers SQL
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh && \
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
chmod 644 /docker-entrypoint-initdb.d/init_db_template.sql && \
|
|
||||||
chmod -R 777 /var/lib/mysql
|
|
||||||
|
|
||||||
# Exposer le port 3306
|
|
||||||
EXPOSE 3306
|
|
||||||
|
|
||||||
# Utiliser le script d'entrée
|
# Utiliser le script d'entrée
|
||||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["mariadbd"]
|
||||||
19
srcs/requirements/mariadb/conf/50-server.cnf
Normal file
19
srcs/requirements/mariadb/conf/50-server.cnf
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[server]
|
||||||
|
|
||||||
|
[mysql]
|
||||||
|
default-character-set=utf8
|
||||||
|
|
||||||
|
[mysqld]
|
||||||
|
|
||||||
|
user = mysql
|
||||||
|
user = mysql
|
||||||
|
socket = /run/mysqld/mysqld.sock
|
||||||
|
pid-file = /run/mysqld/mysqld.pid
|
||||||
|
basedir = /usr
|
||||||
|
datadir = /var/lib/mysql
|
||||||
|
tmpdir = /tmp
|
||||||
|
lc-messages-dir = /usr/share/mysql
|
||||||
|
lc-messages = en_US
|
||||||
|
skip-external-locking
|
||||||
|
|
||||||
|
bind-address = 0.0.0.0
|
||||||
20
srcs/requirements/mariadb/tools/entrypoint.sh
Normal file
20
srcs/requirements/mariadb/tools/entrypoint.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Starting MariaDB..."
|
||||||
|
service mariadb start
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
echo "Creating user..."
|
||||||
|
mysql -e "CREATE USER IF NOT EXISTS \`${MYSQL_USER}\`@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';"
|
||||||
|
mysql -e "GRANT ALL PRIVILEGES ON \`${MYSQL_DATABASE}\`.* TO '${MYSQL_USER}'@'%';"
|
||||||
|
|
||||||
|
mysql -e "FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
echo "Generating database..."
|
||||||
|
mysql -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE};"
|
||||||
|
|
||||||
|
echo "Stopping MariaDB..."
|
||||||
|
mysqladmin -u root shutdown
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
@ -1,4 +1,4 @@
|
|||||||
FROM debian:buster
|
FROM debian:bullseye
|
||||||
|
|
||||||
# Installer Nginx et OpenSSL
|
# Installer Nginx et OpenSSL
|
||||||
RUN apt update -y && apt upgrade -y
|
RUN apt update -y && apt upgrade -y
|
||||||
@ -9,13 +9,13 @@ RUN mkdir -p /etc/nginx/ssl
|
|||||||
|
|
||||||
# Copier les configurations de Nginx et le fichier default
|
# Copier les configurations de Nginx et le fichier default
|
||||||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY ./conf/default /etc/nginx/sites-available/default
|
|
||||||
|
|
||||||
# Générer des certificats auto-signés pour SSL
|
# Générer des certificats auto-signés pour SSL
|
||||||
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/inception.key -out /etc/nginx/ssl/inception.crt -subj "/C=FR/ST=IDF/L=Paris/O=42/OU=42/CN=fgras-ca.42.fr"
|
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/inception.key -out /etc/nginx/ssl/inception.crt -subj "/C=FR/ST=IDF/L=Perpignan/O=42/OU=42/CN=fgras-ca.42.fr"
|
||||||
|
|
||||||
# Supprimer le lien symbolique existant et créer un nouveau lien symbolique pour le site par défaut
|
RUN mkdir -p /run/nginx
|
||||||
RUN rm -f /etc/nginx/sites-enabled/default && ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
|
|
||||||
|
EXPOSE 443
|
||||||
|
|
||||||
# Démarrer Nginx
|
# Démarrer Nginx
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
41
srcs/requirements/nginx/conf/nginx.conf
Normal file
41
srcs/requirements/nginx/conf/nginx.conf
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
events{}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
|
||||||
|
# SSL certificates
|
||||||
|
ssl_certificate /etc/nginx/ssl/inception.crt;
|
||||||
|
ssl_certificate_key /etc/nginx/ssl/inception.key;
|
||||||
|
|
||||||
|
root /var/www/html;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
server_name fgras-ca.42.fr;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
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; # Full path to the script file
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info; # Extra path information
|
||||||
|
fastcgi_param QUERY_STRING $query_string; # Query string
|
||||||
|
fastcgi_param REQUEST_METHOD $request_method; # HTTP request method
|
||||||
|
fastcgi_param CONTENT_TYPE $content_type; # Content type
|
||||||
|
fastcgi_param CONTENT_LENGTH $content_length; # Content length
|
||||||
|
fastcgi_param SERVER_NAME $server_name; # Server name
|
||||||
|
fastcgi_param SERVER_PORT $server_port; # Server port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,8 @@
|
|||||||
FROM debian:buster
|
FROM debian:bullseye
|
||||||
|
|
||||||
# Installer les paquets nécessaires
|
# Installer les paquets nécessaires
|
||||||
RUN apt update -y && apt upgrade -y && \
|
RUN apt update -y && apt upgrade -y && \
|
||||||
apt-get install -y php7.3-fpm php7.3-mysql mariadb-client wget curl vim && \
|
apt-get install -y php7.4-fpm php7.4-mysql mariadb-client wget curl vim && \
|
||||||
mkdir -p /var/www/html && \
|
mkdir -p /var/www/html && \
|
||||||
wget https://fr.wordpress.org/wordpress-6.0-fr_FR.tar.gz -O /tmp/wordpress.tar.gz && \
|
wget https://fr.wordpress.org/wordpress-6.0-fr_FR.tar.gz -O /tmp/wordpress.tar.gz && \
|
||||||
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1 && \
|
tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1 && \
|
||||||
@ -12,7 +12,7 @@ RUN apt update -y && apt upgrade -y && \
|
|||||||
#RUN apt-get install sendmail -y
|
#RUN apt-get install sendmail -y
|
||||||
|
|
||||||
# Copier les fichiers de configuration PHP et le script d'auto-configuration
|
# Copier les fichiers de configuration PHP et le script d'auto-configuration
|
||||||
COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
|
COPY ./conf/www.conf /etc/php/7.4/fpm/pool.d/www.conf
|
||||||
COPY ./conf/wp-config.php /var/www/html/
|
COPY ./conf/wp-config.php /var/www/html/
|
||||||
COPY ./tools/auto_config.sh /usr/local/bin/
|
COPY ./tools/auto_config.sh /usr/local/bin/
|
||||||
|
|
||||||
@ -25,6 +25,8 @@ RUN chmod -R 777 /var/www/html
|
|||||||
COPY ./conf/web /var/www/html
|
COPY ./conf/web /var/www/html
|
||||||
RUN chmod -R 777 /var/www/html
|
RUN chmod -R 777 /var/www/html
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/auto_config.sh"]
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/auto_config.sh"]
|
CMD ["php-fpm7.4", "-F"]
|
||||||
|
Before Width: | Height: | Size: 740 KiB After Width: | Height: | Size: 740 KiB |
|
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 380 KiB |
@ -4,15 +4,6 @@
|
|||||||
mkdir -p /run/php
|
mkdir -p /run/php
|
||||||
chown www-data:www-data /run/php
|
chown www-data:www-data /run/php
|
||||||
|
|
||||||
# Assurez-vous que PHP-FPM est arrêté avant de le démarrer en mode non daemonisé
|
|
||||||
service php7.3-fpm stop
|
|
||||||
|
|
||||||
# Attendre que MariaDB soit prêt
|
|
||||||
until mysqladmin ping -h mariadb --silent; do
|
|
||||||
echo "Waiting for MariaDB to be ready..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
|
|
||||||
# Télécharger WP-CLI si nécessaire
|
# Télécharger WP-CLI si nécessaire
|
||||||
if [ ! -f /usr/local/bin/wp ]; then
|
if [ ! -f /usr/local/bin/wp ]; then
|
||||||
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||||
@ -37,6 +28,4 @@ else
|
|||||||
echo "=== WordPress is already installed ==="
|
echo "=== WordPress is already installed ==="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Démarrer PHP-FPM en mode non daemonisé
|
exec "$@"
|
||||||
php-fpm7.3 -F
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user