diff --git a/.gitignore b/.gitignore index e69de29..adbb97d 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +data/ \ No newline at end of file diff --git a/secrets/credentials.txt b/secrets/credentials.txt deleted file mode 100644 index e69de29..0000000 diff --git a/secrets/db_password.txt b/secrets/db_password.txt deleted file mode 100644 index e69de29..0000000 diff --git a/secrets/db_root_password.txt b/secrets/db_root_password.txt deleted file mode 100644 index e69de29..0000000 diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 0d27ead..c13e4db 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -20,17 +20,21 @@ services: - data_mariadb:/var/lib/mysql - # nginx: - # restart: always - # build: - # context: ./requirements/nginx - # dockerfile: Dockerfile - # ports: - # - '443:443' - # networks: - # - docker-network - # volumes: - # - data_wordpress:/var/www/html + nginx: + restart: always + container_name: nginx + build: + context: ./requirements/nginx + dockerfile: Dockerfile + depends_on: + - wordpress + ports: + - '443:443' + - '80:80' + networks: + - docker-network + volumes: + - data_wordpress:/var/www/html wordpress: container_name: wordpress @@ -46,8 +50,7 @@ services: - MYSQL_DATABASE=wordpress - MYSQL_USER=wordpress - MYSQL_PASSWORD=42wordpress42 - - MYSQL_ROOT_PASSWORD=42root42 - + - DB_HOST=mariadb - DB_PORT=3306 diff --git a/srcs/requirements/nginx/Dockerfile b/srcs/requirements/nginx/Dockerfile index c51fb48..4eb3c91 100644 --- a/srcs/requirements/nginx/Dockerfile +++ b/srcs/requirements/nginx/Dockerfile @@ -4,3 +4,6 @@ RUN apk add --no-cache \ nginx &&\ rm -rf /var/cache/apk/* +COPY ./conf/nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/srcs/requirements/nginx/conf/nginx.conf b/srcs/requirements/nginx/conf/nginx.conf index cefb4c1..19480ec 100644 --- a/srcs/requirements/nginx/conf/nginx.conf +++ b/srcs/requirements/nginx/conf/nginx.conf @@ -1,20 +1,33 @@ -server { - listen 80; - server_name ${DOMAIN_NAME}; - root /var/www/html/wordpress; +user nginx; +worker_processes 1; - access_log /var/log/nginx/example.${DOMAIN_NAME}-access.log; - error_log /var/log/nginx/example.${DOMAIN_NAME}-error.log error; - index index.html index.htm index.php; +events { + worker_connections 1024; +} - location / { - try_files $uri $uri/ /index.php$is_args$args; - } +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; - location ~ \.php$ { + server { + listen 80; + server_name localhost; + root /var/www/html; + + access_log /var/log/nginx/example.localhost-access.log; + error_log /var/log/nginx/example.localhost-error.log error; + index index.html index.htm index.php; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass wordpress:9000; fastcgi_index index.php; include fastcgi.conf; + } } + } \ No newline at end of file diff --git a/srcs/requirements/wordpress/Dockerfile b/srcs/requirements/wordpress/Dockerfile index 087c978..37678f9 100644 --- a/srcs/requirements/wordpress/Dockerfile +++ b/srcs/requirements/wordpress/Dockerfile @@ -29,6 +29,8 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli chmod +x wp-cli.phar && \ mv wp-cli.phar /usr/local/bin/wp +COPY ./conf/www.conf /etc/php83/php-fpm.d/www.conf + RUN echo "memory_limit = 512M" >> /etc/php83/php.ini # Copy and set permissions for the install script diff --git a/srcs/requirements/wordpress/conf/www.conf b/srcs/requirements/wordpress/conf/www.conf new file mode 100644 index 0000000..085cb60 --- /dev/null +++ b/srcs/requirements/wordpress/conf/www.conf @@ -0,0 +1,10 @@ +[www] +listen = 0.0.0.0:9000 +user = wordpress +group = wordpress +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +catch_workers_output = yes \ No newline at end of file diff --git a/srcs/requirements/wordpress/tools/install.sh b/srcs/requirements/wordpress/tools/install.sh index 17e95e9..4bfd993 100644 --- a/srcs/requirements/wordpress/tools/install.sh +++ b/srcs/requirements/wordpress/tools/install.sh @@ -7,13 +7,19 @@ echo "Installing WordPress..." sleep 10 # Check if the database exists + +echo "wp core download --allow-root --path=/var/www/html" wp core download --allow-root --path=/var/www/html + +echo "wp config create --allow-root" wp config create --allow-root \ --dbname=$MYSQL_DATABASE \ --dbuser=$MYSQL_USER \ --dbpass=$MYSQL_PASSWORD \ --dbhost=$DB_HOST \ --path=/var/www/html + +echo "wp core install --allow-root" wp core install --allow-root \ --url=$DOMAIN_NAME \ --title=$WP_TITLE \ @@ -21,12 +27,16 @@ wp core install --allow-root \ --admin_password=$WP_ADMIN_PASSWORD \ --admin_email=$WP_ADMIN_EMAIL \ --path=/var/www/html + +echo "wp user create --allow-root" wp user create --allow-root \ $WP_USER \ $WP_USER_EMAIL \ --role=author \ --user_pass=$WP_USER_PASSWORD \ --path=/var/www/html + +echo "wp theme install --allow-root" wp theme install --allow-root \ $WP_THEME \ --activate \