Compare commits
No commits in common. "4a600575131e282c16580513ddbdd7fe0b335ac2" and "663aefc78293bfa8b6d869e3caa831331e483e6c" have entirely different histories.
4a60057513
...
663aefc782
12 changed files with 30 additions and 250 deletions
55
Makefile
55
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/06/12 18:09:23 by rparodi #+# #+# #
|
# Created: 2025/06/12 18:09:23 by rparodi #+# #+# #
|
||||||
# Updated: 2025/06/27 17:23:54 by rparodi ### ########.fr #
|
# Updated: 2025/06/14 18:26:21 by rparodi ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -34,10 +34,10 @@ all: header get_secret build footer
|
||||||
build:
|
build:
|
||||||
docker compose -f $(MAIN)/docker-compose.yml up --build -d
|
docker compose -f $(MAIN)/docker-compose.yml up --build -d
|
||||||
|
|
||||||
stop: header
|
stop:
|
||||||
@docker compose -f $(MAIN)/docker-compose.yml stop
|
@docker compose -f $(MAIN)/docker-compose.yml down
|
||||||
@if [ $(shell docker ps -q | wc -l) -ne 0 ]; then \
|
@if [ $(shell docker ps -q | wc -l) -ne 0 ]; then \
|
||||||
docker stop $(shell docker ps -q); \
|
docker stop $(docker ps -q); \
|
||||||
fi
|
fi
|
||||||
@printf '$(GREY)Stopping all the $(RED)Containers$(END)\n';
|
@printf '$(GREY)Stopping all the $(RED)Containers$(END)\n';
|
||||||
|
|
||||||
|
|
@ -66,16 +66,15 @@ wordpress:
|
||||||
docker build -t wordpress-test $(WORDPRESS)
|
docker build -t wordpress-test $(WORDPRESS)
|
||||||
|
|
||||||
get_secret:
|
get_secret:
|
||||||
|
@if [ ! -d $(SECRET) ]; then \
|
||||||
#@if [ ! -d $(SECRET) ]; then \
|
printf "$(RED)The secrets home folder doesn't exist$(END)\n"; \
|
||||||
# printf "$(RED)The secrets home folder doesn't exist$(END)\n"; \
|
exit 1; \
|
||||||
# exit 1; \
|
elif [ ! -d $(shell pwd)/secrets ]; then \
|
||||||
#elif [ ! -d $(shell pwd)/secrets ]; then \
|
cp -r $(SECRET) $(shell pwd)/secrets; \
|
||||||
# cp -r $(SECRET) $(shell pwd)/secrets; \
|
printf '$(GREY)Creating the folder $(GREEN)$(shell pwd)/secrets$(END)\n'; \
|
||||||
# printf '$(GREY)Creating the folder $(GREEN)$(shell pwd)/secrets$(END)\n'; \
|
else \
|
||||||
#else \
|
printf '$(GREY)The secrets is $(RED)already existing$(END)\n'; \
|
||||||
# printf '$(GREY)The secrets is $(RED)already existing$(END)\n'; \
|
fi
|
||||||
#fi
|
|
||||||
|
|
||||||
clean: stop
|
clean: stop
|
||||||
@printf '$(GREY)Suppressing all the $(RED)Containers$(END)\n';
|
@printf '$(GREY)Suppressing all the $(RED)Containers$(END)\n';
|
||||||
|
|
@ -84,25 +83,25 @@ clean: stop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
docker image prune -f -a
|
@if [ $(shell docker images -aq | wc -l) -ne 0 ]; then \
|
||||||
|
docker rmi -f $(shell docker images -aq); \
|
||||||
|
fi
|
||||||
@printf '$(GREY)Suppressing all the $(RED)Images$(END)\n';
|
@printf '$(GREY)Suppressing all the $(RED)Images$(END)\n';
|
||||||
docker volume prune -fa
|
@if [ $(shell docker volume ls -q | wc -l) -ne 0 ]; then \
|
||||||
|
docker volume rm $(shell docker volume ls -q); \
|
||||||
|
fi
|
||||||
@printf '$(GREY)Suppressing all the $(RED)Volumes$(END)\n';
|
@printf '$(GREY)Suppressing all the $(RED)Volumes$(END)\n';
|
||||||
docker system prune -f -a
|
@if [ $(shell docker network ls | grep -v "bridge\|host\|none\|NETWORK" | awk '{print $1}' | wc -l) -ne 0 ]; then \
|
||||||
|
docker network rm $(shell docker network ls | grep -v "bridge\|host\|none\|NETWORK" | awk '{print $1}'); \
|
||||||
|
fi
|
||||||
@printf '$(GREY)Suppressing all the $(RED)Network$(END)\n';
|
@printf '$(GREY)Suppressing all the $(RED)Network$(END)\n';
|
||||||
|
|
||||||
re: header fclean all footer
|
re: header fclean all footer
|
||||||
|
|
||||||
setup_vm: header
|
setup_vm:
|
||||||
@echo "127.0.0.1 rparodi.42.fr" | sudo tee -a /etc/hosts &> /dev/null
|
sudo $(PACK_MAN) docker docker-compose
|
||||||
@printf "$(GREY)Adding the custom host $(GREEN)rparodi.42.fr$(END)\n";
|
sudo usermod -aG docker $(shell whoami)
|
||||||
@sudo $(PACK_MAN) docker docker-compose docker-buildx &> /dev/null
|
@printf '$(GREY)Virtual Machine now$(GREEN)setuped$(END)\n'; \
|
||||||
@printf "$(GREY)Install the $(GREEN)docker docker-compose docker-buildx packages$(END)\n";
|
|
||||||
@sudo usermod -aG docker $(shell whoami)
|
|
||||||
@printf "$(GREY)User add to the $(GREEN)docker's group$(END)\n";
|
|
||||||
@printf "$(GREY)Virtual Machine now $(GOLD)setuped$(END)\n";
|
|
||||||
|
|
||||||
setup: setup_vm
|
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
header:
|
header:
|
||||||
|
|
@ -136,4 +135,4 @@ footer:
|
||||||
@printf ' $(GREY)The build is $(GOLD)finished$(END)\n $(GREY)Have a good $(GOLD)evaluation !$(END)\n'
|
@printf ' $(GREY)The build is $(GOLD)finished$(END)\n $(GREY)Have a good $(GOLD)evaluation !$(END)\n'
|
||||||
|
|
||||||
# Phony
|
# Phony
|
||||||
.PHONY: all nginx mariadb wordpress get_secret clean fclean re setup setup_vm
|
.PHONY: all nginx mariadb wordpress get_secret clean fclean re
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
### Usefull links
|
### Usefull links
|
||||||
- [Docker](https://docs.docker.com/reference/)
|
(Docker)[https://docs.docker.com/reference/]
|
||||||
- [MariaDB](https://mariadb.com/kb/en/creating-a-custom-container-image/)
|
(MariaDB)[https://mariadb.com/kb/en/creating-a-custom-container-image/]
|
||||||
- [Nginx](https://nginx.org/en/docs/beginners_guide.html)
|
(Nginx)[https://nginx.org/en/docs/beginners_guide.html]
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
services:
|
|
||||||
|
|
||||||
mariadb:
|
|
||||||
build: ./requirements/mariadb
|
|
||||||
container_name: mariadb
|
|
||||||
image: mariadb
|
|
||||||
env_file:
|
|
||||||
- ../secrets/.env
|
|
||||||
volumes:
|
|
||||||
- wp_db:/var/lib/mysql
|
|
||||||
networks:
|
|
||||||
- inception
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
wordpress:
|
|
||||||
container_name: wordpress
|
|
||||||
image: wordpress
|
|
||||||
build: ./requirements/wordpress
|
|
||||||
env_file:
|
|
||||||
- ../secrets/.env
|
|
||||||
depends_on:
|
|
||||||
- mariadb
|
|
||||||
ports:
|
|
||||||
- 9000:9000
|
|
||||||
volumes:
|
|
||||||
- wp_files:/var/www/html
|
|
||||||
networks:
|
|
||||||
- inception
|
|
||||||
|
|
||||||
nginx:
|
|
||||||
container_name: nginx
|
|
||||||
image: nginx
|
|
||||||
env_file:
|
|
||||||
- ../secrets/.env
|
|
||||||
build: ./requirements/nginx
|
|
||||||
extra_hosts:
|
|
||||||
- "rparodi.42.fr:127.0.0.1"
|
|
||||||
ports:
|
|
||||||
- 443:443
|
|
||||||
volumes:
|
|
||||||
- wp_files:/var/www/html
|
|
||||||
depends_on:
|
|
||||||
- wordpress
|
|
||||||
networks:
|
|
||||||
- inception
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
wp_files:
|
|
||||||
wp_db:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
inception:
|
|
||||||
driver: bridge
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
FROM alpine:3.21
|
|
||||||
|
|
||||||
RUN apk update && apk add sudo mariadb mariadb-client bash;
|
|
||||||
|
|
||||||
RUN mkdir -p /var/lib/mysqld;
|
|
||||||
RUN mkdir -p /run/mysqld;
|
|
||||||
RUN chown -R mysql:mysql /run/mysqld;
|
|
||||||
RUN chown -R mysql:mysql /var/lib/mysqld;
|
|
||||||
|
|
||||||
EXPOSE 3306
|
|
||||||
|
|
||||||
RUN /usr/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql;
|
|
||||||
|
|
||||||
COPY tools/start_db.sh /usr/bin/start_db
|
|
||||||
RUN chmod +x /usr/bin/start_db;
|
|
||||||
|
|
||||||
CMD ["start_db"]
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
sudo -u mysql -s /bin/sh -c mysqld &
|
|
||||||
PID=$!
|
|
||||||
|
|
||||||
mariadb-admin status --wait
|
|
||||||
|
|
||||||
mariadb -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME};"
|
|
||||||
mariadb -e "CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASSWORD}';"
|
|
||||||
mariadb -e "GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'%';"
|
|
||||||
mariadb -e "FLUSH PRIVILEGES;"
|
|
||||||
|
|
||||||
sudo -u mysql -s /bin/sh -c "mysqladmin shutdown"
|
|
||||||
wait "$PID"
|
|
||||||
|
|
||||||
sed -i /etc/my.cnf.d/mariadb-server.cnf -e 's/^port=3307$/\0\nbind-address = 0.0.0.0/'
|
|
||||||
sed -i /etc/my.cnf.d/mariadb-server.cnf -e 's/^skip-networking$/;\0/'
|
|
||||||
|
|
||||||
exec sudo -u mysql -s /bin/sh -c mysqld
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
FROM alpine:3.21
|
|
||||||
|
|
||||||
RUN apk update
|
|
||||||
RUN apk add nginx openssl bash
|
|
||||||
|
|
||||||
RUN mkdir -p /run/nginx /etc/nginx/ssl
|
|
||||||
|
|
||||||
RUN rm -rf /var/www/html;
|
|
||||||
COPY conf/nginx.conf /etc/nginx/nginx.conf
|
|
||||||
COPY tools/generate_ssl_certificate.sh /usr/bin/generate_ssl_certificate
|
|
||||||
|
|
||||||
RUN chmod +x /usr/bin/generate_ssl_certificate
|
|
||||||
|
|
||||||
EXPOSE 443
|
|
||||||
|
|
||||||
CMD ["generate_ssl_certificate"]
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
# /etc/nginx/nginx.conf
|
|
||||||
# disable daemonization
|
|
||||||
daemon off;
|
|
||||||
# basically the default config. stolen from the container before overriting
|
|
||||||
error_log stderr info;
|
|
||||||
pcre_jit on;
|
|
||||||
# user wordpress;
|
|
||||||
worker_processes auto;
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
http {
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
server_tokens off;
|
|
||||||
client_max_body_size 1m;
|
|
||||||
sendfile on;
|
|
||||||
tcp_nopush on;
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
ssl_session_cache shared:SSL:2m;
|
|
||||||
ssl_session_timeout 1h;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
gzip_vary on;
|
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default upgrade;
|
|
||||||
'' close;
|
|
||||||
}
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
||||||
access_log stderr;
|
|
||||||
# end of default server
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
listen [::]:443 ssl;
|
|
||||||
server_name rparodi.42.fr;
|
|
||||||
|
|
||||||
ssl_certificate /etc/nginx/ssl/nginx.crt;
|
|
||||||
ssl_certificate_key /etc/nginx/ssl/nginx.key;
|
|
||||||
ssl_protocols TLSv1.3;
|
|
||||||
index index.php;
|
|
||||||
root /var/www/html;
|
|
||||||
location ~ [^/]\.php(/|$) {
|
|
||||||
try_files $uri =404;
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_pass wordpress:9000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if [ ! -f "$CERT_DIR/nginx.key" ]; then
|
|
||||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt -subj "/C=FR/ST=Paris/L=42/O=Students/OU=Inception/CN=rparodi.42.fr"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec nginx
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
FROM alpine:3.21
|
|
||||||
|
|
||||||
RUN apk update && apk add php82-curl php82-gd php82-mbstring php82-session php82-opcache php82-zlib bash wget php82 php82-phar php82-mysqli php82-fpm mariadb-client;
|
|
||||||
|
|
||||||
# RUN wget https://wordpress.org/latest.tar.gz -O /tmp/wp.tar.gz
|
|
||||||
|
|
||||||
RUN mkdir -p /var/www/html;
|
|
||||||
|
|
||||||
RUN wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /bin/wp-cli.phar;
|
|
||||||
RUN chmod +x /bin/wp-cli.phar;
|
|
||||||
RUN mv /bin/wp-cli.phar /bin/wp;
|
|
||||||
|
|
||||||
RUN ln -s /usr/bin/php82 /usr/bin/php;
|
|
||||||
RUN ln -s /usr/sbin/php-fpm82 /usr/sbin/php-fpm;
|
|
||||||
|
|
||||||
RUN adduser -D wordpress -g wordpress;
|
|
||||||
RUN chown wordpress:wordpress -R /var/www/html;
|
|
||||||
RUN chmod -R +rw /var/www/html;
|
|
||||||
RUN chmod -R +rw /var/log/php82/;
|
|
||||||
|
|
||||||
COPY tools/install.sh /usr/bin/install-wp
|
|
||||||
RUN chmod +x /usr/bin/install-wp;
|
|
||||||
|
|
||||||
COPY ./conf/php-fpm.conf /etc/php82/php-fpm.d/www.conf
|
|
||||||
RUN sed -i 's/^memory_limit\s*=.*/memory_limit = 1024M/' /etc/php82/php.ini;
|
|
||||||
USER wordpress
|
|
||||||
|
|
||||||
CMD ["install-wp"]
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
[global]
|
|
||||||
daemonize = false
|
|
||||||
error_log = /dev/stderr
|
|
||||||
|
|
||||||
[www]
|
|
||||||
listen = 0.0.0.0:9000
|
|
||||||
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 25
|
|
||||||
pm.start_servers = 5
|
|
||||||
pm.min_spare_servers = 1
|
|
||||||
pm.max_spare_servers = 10
|
|
||||||
access.log = /dev/stderr
|
|
||||||
catch_workers_output = yes
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -xe
|
|
||||||
mysqladmin --host=mariadb --port=3306 --user="$DB_USER" --password="$DB_PASSWORD" --wait status
|
|
||||||
|
|
||||||
if ! [ -e /var/www/html/wp-config.php ]; then
|
|
||||||
wp core download --locale=fr_FR --allow-root --path=/var/www/html
|
|
||||||
wp config create --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASSWORD --dbhost=$DB_HOST --skip-check --path=/var/www/html --allow-root
|
|
||||||
wp core install --url=$DOMAIN --title="$WP_TITLE" --admin_user=$WP_ADMIN --admin_password=$WP_PASS_ADMIN --admin_email=$WP_MAIL_ADMIN --path=/var/www/html --allow-root
|
|
||||||
wp user create "$WP_USER" "$WP_MAIL" --user_pass="$WP_PASS" --role=editor --path=/var/www/html
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec php-fpm -F
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue