trying to commit with my voyager is too complicated at the moment
This commit is contained in:
parent
778e1a9056
commit
4a60057513
10 changed files with 130 additions and 62 deletions
23
Makefile
23
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/06/12 18:09:23 by rparodi #+# #+# #
|
||||
# Updated: 2025/06/17 00:07:38 by rparodi ### ########.fr #
|
||||
# Updated: 2025/06/27 17:23:54 by rparodi ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -66,15 +66,16 @@ wordpress:
|
|||
docker build -t wordpress-test $(WORDPRESS)
|
||||
|
||||
get_secret:
|
||||
@if [ ! -d $(SECRET) ]; then \
|
||||
printf "$(RED)The secrets home folder doesn't exist$(END)\n"; \
|
||||
exit 1; \
|
||||
elif [ ! -d $(shell pwd)/secrets ]; then \
|
||||
cp -r $(SECRET) $(shell pwd)/secrets; \
|
||||
printf '$(GREY)Creating the folder $(GREEN)$(shell pwd)/secrets$(END)\n'; \
|
||||
else \
|
||||
printf '$(GREY)The secrets is $(RED)already existing$(END)\n'; \
|
||||
fi
|
||||
|
||||
#@if [ ! -d $(SECRET) ]; then \
|
||||
# printf "$(RED)The secrets home folder doesn't exist$(END)\n"; \
|
||||
# exit 1; \
|
||||
#elif [ ! -d $(shell pwd)/secrets ]; then \
|
||||
# cp -r $(SECRET) $(shell pwd)/secrets; \
|
||||
# printf '$(GREY)Creating the folder $(GREEN)$(shell pwd)/secrets$(END)\n'; \
|
||||
#else \
|
||||
# printf '$(GREY)The secrets is $(RED)already existing$(END)\n'; \
|
||||
#fi
|
||||
|
||||
clean: stop
|
||||
@printf '$(GREY)Suppressing all the $(RED)Containers$(END)\n';
|
||||
|
|
@ -85,7 +86,7 @@ clean: stop
|
|||
fclean: clean
|
||||
docker image prune -f -a
|
||||
@printf '$(GREY)Suppressing all the $(RED)Images$(END)\n';
|
||||
docker volume prune -f
|
||||
docker volume prune -fa
|
||||
@printf '$(GREY)Suppressing all the $(RED)Volumes$(END)\n';
|
||||
docker system prune -f -a
|
||||
@printf '$(GREY)Suppressing all the $(RED)Network$(END)\n';
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ services:
|
|||
- ../secrets/.env
|
||||
depends_on:
|
||||
- mariadb
|
||||
ports:
|
||||
- 9000:9000
|
||||
volumes:
|
||||
- wp_files:/var/www/html
|
||||
networks:
|
||||
- inception
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
FROM alpine:3.21
|
||||
|
||||
RUN apk update && apk add mariadb mariadb-client bash
|
||||
RUN apk update && apk add sudo mariadb mariadb-client bash;
|
||||
|
||||
RUN mkdir -p /run/mysqld && chown -R mysql:mysql /run/mysqld
|
||||
|
||||
HEALTHCHECK --start-period=5m CMD mariadb -e 'SELECT @@datadir;' || exit 1
|
||||
|
||||
RUN mysql_install_db --user=$DB_USER --basedir=/usr --datadir=/var/lib/mysql
|
||||
|
||||
USER mysql
|
||||
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
|
||||
|
||||
CMD ["mariadbd"]
|
||||
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"]
|
||||
|
|
|
|||
19
srcs/requirements/mariadb/tools/start_db.sh
Normal file
19
srcs/requirements/mariadb/tools/start_db.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#!/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
|
||||
|
|
@ -5,13 +5,12 @@ 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
|
||||
|
||||
RUN /usr/bin/generate_ssl_certificate
|
||||
|
||||
EXPOSE 443
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
CMD ["generate_ssl_certificate"]
|
||||
|
|
|
|||
|
|
@ -1,16 +1,52 @@
|
|||
# /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 {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
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_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_certificate /etc/nginx/ssl/nginx.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/nginx.key;
|
||||
|
||||
root /var/www/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
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,14 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
GREEN = \033[32m
|
||||
GREY = \033[0;90m
|
||||
RED = \033[0;31m
|
||||
GOLD = \033[38;5;220m
|
||||
END = \033[0m
|
||||
|
||||
if [ ! -f "$CERT_DIR/nginx.key" ]; then
|
||||
@printf '$GREYGenerating the ssl$GREEN Certificate$END\n';
|
||||
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=$DOMAIN"
|
||||
else
|
||||
@printf '$GREYGenerating the ssl certificate$RED already exist$END\n';
|
||||
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,10 +1,10 @@
|
|||
FROM alpine:3.21
|
||||
|
||||
RUN apk update && apk add bash wget php82 php82-phar php82-mysqli php82-fpm mariadb-client
|
||||
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 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;
|
||||
|
|
@ -12,10 +12,17 @@ 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 export PHP_OPTIONS="-d memory_limit=512M"
|
||||
|
||||
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;
|
||||
|
||||
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", "php-fpm"]
|
||||
CMD ["install-wp"]
|
||||
|
|
|
|||
14
srcs/requirements/wordpress/conf/php-fpm.conf
Normal file
14
srcs/requirements/wordpress/conf/php-fpm.conf
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[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,19 +1,12 @@
|
|||
#!/bin/sh
|
||||
set -xe
|
||||
mysqladmin --host=mariadb --port=3306 --user="$DB_USER" --password="$DB_PASSWORD" --wait status
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
mariadb-admin --host=mariadb --port=3306 --user="$DB_USER" --password="$DB_PASS" --wait status
|
||||
|
||||
if ! [ -f wp-load.php ]; then
|
||||
if ! [ -e /var/www/html/wp-config.php ]; then
|
||||
wp core download --locale=fr_FR --allow-root --path=/var/www/html
|
||||
fi
|
||||
|
||||
if ! [ -f wp-config.php ]; then
|
||||
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 --skip-email --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
|
||||
|
||||
chown wordpress:wordpress -R /var/www/html
|
||||
chmod -R +rw /var/www/html
|
||||
|
||||
exec php-fpm --nodeamonize
|
||||
exec php-fpm -F
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue