From c9b6086e7f247576aafcaaa9a42ea9875fe62319 Mon Sep 17 00:00:00 2001 From: amine zaghloul <115177542+amine-za@users.noreply.github.com> Date: Mon, 1 Jul 2024 19:56:09 +0000 Subject: [PATCH] left only WP conf file --- srcs/.env | 1 + srcs/docker-compose.yml | 43 ++++++++++++++----- srcs/requirements/wordpress/Dockerfile | 39 +++++++++++++++++ .../wordpress/conf/wp-config-create.sh | 9 ++++ srcs/requirements/wordpress/tools/script.sh | 9 ++++ 5 files changed, 91 insertions(+), 10 deletions(-) create mode 100755 srcs/requirements/wordpress/tools/script.sh diff --git a/srcs/.env b/srcs/.env index 227037a..e0dbd7d 100644 --- a/srcs/.env +++ b/srcs/.env @@ -5,3 +5,4 @@ DB_NAME=wordpress DB_ROOT=rootpass DB_USER=wpuser DB_PASS=wppass +DB_HOST=mariadb:3306 \ No newline at end of file diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index a4195d1..a194ade 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -1,27 +1,50 @@ version: '3' services: + + nginx: + build: + context: . + dockerfile: requirements/nginx/Dockerfile + container_name: nginx + depends_on: + - wordpress + ports: + - "443:443" + volumes: + - /home/${USER}/simple_docker_nginx_html/public/html:/var/www/ + networks: + - my_network + restart: always + mariadb: build: context: . dockerfile: requirements/mariadb/Dockerfile - container_name: mariadb env_file: .env + container_name: mariadb ports: - "3306:3306" + networks: + - my_network restart: always - nginx: + wordpress: build: context: . - dockerfile: requirements/nginx/Dockerfile - container_name: nginx - #depends_on: - # - wordpress - ports: - - "443:443" - volumes: - - /home/${USER}/simple_docker_nginx_html/public/html:/var/www/ + dockerfile: requirements/wordpress/Dockerfile + env_file: .env + container_name: wordpress + depends_on: + - mariadb restart: always + volumes: + - /home/${USER}/simple_docker_nginx_html/public/html:/var/www/ + # - wp-volume:/var/www/ + networks: + - my_network +networks: + my_network: + driver: bridge \ No newline at end of file diff --git a/srcs/requirements/wordpress/Dockerfile b/srcs/requirements/wordpress/Dockerfile index b511df0..14aae45 100644 --- a/srcs/requirements/wordpress/Dockerfile +++ b/srcs/requirements/wordpress/Dockerfile @@ -1,2 +1,41 @@ FROM alpine:3.18 +RUN apk update && apk upgrade && apk add --no-cache php82 php82-fpm php82-mysqli php82-json php82-curl \ + php82-dom php82-exif php82-fileinfo php82-mbstring php82-openssl php82-xml php82-zip wget unzip + +# FPM: FastCGI Process Manager. +# MYSQLI: A php extension for interactiong with MYSQL database in a secure way, +# connect to database, fetch and insert data... +# JSON: Json data format cmnly used for exchanging inf btwn apps, widly usd for APIs. +# php-curl: php-curl is all about enabling your PHP scripts to make requests to +# other servers and services over the internet using http and other prtcls. +# php-dom: - +# php-exif: - +# php-fileinfo: Provides functionality to determine file types and properties. +# php-mbstring: Enables multi-byte string handling for character sets beyond basic ASCII. +# php-openssl: Offers secure communication capabilities using SSL and TLS. +# php-xml: - +# php-zip: Allows you to create and work with ZIP archives in your PHP code. +# wget: A command-line tool for downloading files from the internet. +# unzip: A command-line tool for extracting ZIP archives. + +RUN sed -i "s|listen = 127.0.0.1:9000|listen = 9000|g" /etc/php82/php-fpm.d/www.conf && \ + sed -i "s|;listen.owner = nobody|listen.owner = nobody|g" /etc/php82/php-fpm.d/www.conf && \ + sed -i "s|;listen.group = nobody|listen.group = nobody|g" /etc/php82/php-fpm.d/www.conf && \ + rm -f /var/cache/apk/* + +WORKDIR /tmp + +RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \ + chmod +x wp-cli.phar && \ + mv wp-cli.phar /usr/local/bin/wp + +WORKDIR /var/www + +COPY requirements/wordpress/conf/wp-config-create.sh . + +RUN sh wp-config-create.sh && \ + rm wp-config-create.sh && \ + chmod -R 777 wp-content/ + +CMD ["/usr/sbin/php-fpm82", "-F"] \ No newline at end of file diff --git a/srcs/requirements/wordpress/conf/wp-config-create.sh b/srcs/requirements/wordpress/conf/wp-config-create.sh index e69de29..b1175ee 100644 --- a/srcs/requirements/wordpress/conf/wp-config-create.sh +++ b/srcs/requirements/wordpress/conf/wp-config-create.sh @@ -0,0 +1,9 @@ +echo "wp-config-create.sh >>>"; + +wp core download --allow-root + +wp config create --allow-root --dbname=${DB_NAME} --dbuser=${DB_USER} --dbpass=${DB_PASS} --dbhost=${DB_HOST} + +wp core install --allow-root --url=${WP_URL} --title=${WP_TITLE} --admin_user=${WP_ADMIN} --admin_password=${WP_ADMIN_PASSWD} --admin_email=${WP_ADMIN_EMAIL} + +wp user create ${WP_USER} ${WP_USER_EMAIL} --role=editor --user_pass=${WP_PASSWD} --path=/var/www/html/wordpress --allow-root diff --git a/srcs/requirements/wordpress/tools/script.sh b/srcs/requirements/wordpress/tools/script.sh new file mode 100755 index 0000000..2d238f8 --- /dev/null +++ b/srcs/requirements/wordpress/tools/script.sh @@ -0,0 +1,9 @@ +#!/bin/bash + + + +# if [! -d "/home/${USER}/data" ]; then +# mkdir ~/data +# mkdir ~/data/mariadb +# mkdir ~/data/wordpress +# fi \ No newline at end of file