diff --git a/Makefile b/Makefile index 8e1ed57..cf82a74 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ SOURCE_ENV := . $(ENV_PATH) # list of volumes VOLUME_ENV := set | grep "^HOST_VOLUME_" | cut -d "=" -f 2 VOLUMES_D = $(shell $(SOURCE_ENV) ; $(VOLUME_ENV) ) +VOLUMES_D += $(shell $(SOURCE_ENV) ; echo $$HOST_VOLUMES_DIR ) # url for wordpress, use in makefile to change local WP_URL = $(shell $(SOURCE_ENV) ; echo $$WP_URL ) WP_COMPLETE_URL = $(shell $(SOURCE_ENV) ; echo $$WP_COMPLETE_URL ) diff --git a/README.md b/README.md index 508a129..0f409ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ +### to start : + this repo uses submodule fo `env_generator`, so after cloning you need to do : ``` git submodule init @@ -9,3 +11,14 @@ or git submodule update --init --recursive ``` +### PLUGINS : + +- this wordpress container allow you to have a plugins repository outside of +- by default it's in the parent repo : + - parent-repo/ + - stuff.. + - plugins/ + - wordpress_docker/ + - stuff.. +- you can change its location inside `model.env` +- this plugin repository is a volume, so changes inside of it takes immediat effect diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 7463af6..c51be41 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -17,13 +17,14 @@ services: - "${WP_PORT}:443" volumes: - wp_volume:${WP_VOLUME_DIR} + - wp_plugins:${WP_VOLUME_PLUGINS} build: context: ./requirements/nginx args: - WP_URL=${WP_URL} - SERVER_MAX_UPLOAD_SIZE=${SERVER_MAX_UPLOAD_SIZE} - WP_VOLUME_DIR=${WP_VOLUME_DIR} - - NG_VOLUME_CERTS=${NG_VOLUME_CERTS} + - NG_CERTS_DIR=${NG_CERTS_DIR} image: nginx container_name: nginx_container depends_on: @@ -59,6 +60,7 @@ services: - inception volumes: - wp_volume:${WP_VOLUME_DIR} + - wp_plugins:${WP_VOLUME_PLUGINS} build: context: ./requirements/wordpress args: @@ -84,6 +86,12 @@ volumes: type: none o: "bind" device: ${HOST_VOLUME_WP} + wp_plugins: + driver: local + driver_opts: + type: none + o: "bind" + device: ${HOST_VOLUME_PLUGINS} networks: inception: diff --git a/srcs/env_generator b/srcs/env_generator index d26a2b2..536900d 160000 --- a/srcs/env_generator +++ b/srcs/env_generator @@ -1 +1 @@ -Subproject commit d26a2b2902424022a2bfe65decf96c2253dff653 +Subproject commit 536900d1f9c296a9a8665b6f31dc1ec79463c2a7 diff --git a/srcs/model.env b/srcs/model.env index 6301ef9..67b7937 100644 --- a/srcs/model.env +++ b/srcs/model.env @@ -12,7 +12,7 @@ SERVER_MAX_UPLOAD_SIZE=512 # ---------------------------------------------------------------------- # NGINX SETUP -NG_VOLUME_CERTS=/etc/ssl +NG_CERTS_DIR=/etc/ssl # ---------------------------------------------------------------------- @@ -36,7 +36,7 @@ if [ ! ${WP_PORT} -eq 443 ]; then WP_COMPLETE_URL="${WP_URL}:${WP_PORT}" fi WP_VOLUME_DIR=/var/www/html -#WP_VOLUME_PLUGINS=/home/www-data +WP_VOLUME_PLUGINS=/home/www-data WP_TITLE=title WP_ADMIN=admin WP_ADMIN_PSWD="you shall not password !" @@ -73,10 +73,17 @@ WP_ADMIN_EMAIL=admin@email.fr # - because "~username" expand in the home (~) directory of given user # https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected HOST_HOME_PATH=$(eval echo "~$SUDO_USER") +# path to the docker folder containing the srcs/ dir +HOST_DOCKER_PATH=$(realpath ${DIR_PATH}/..) +HOST_DOCKER_PARENT_PATH=$(realpath ${DIR_PATH}/../..) # makefile will create the volumes folders # we put them inside a volumes/ dir, sibling to the srcs/ dir -HOST_VOLUMES_DIR=$(realpath ${DIR_PATH}/../volumes) +# there can be only one variable named "HOST_VOLUMES_DIR", or change the Makefile +HOST_VOLUMES_DIR=${HOST_DOCKER_PATH}/volumes HOST_VOLUME_WP=${HOST_VOLUMES_DIR}/wp_volume HOST_VOLUME_DB=${HOST_VOLUMES_DIR}/db_volume +# we put the plugin folder inside the parent folder of the docker dir +HOST_VOLUME_PLUGINS=${HOST_DOCKER_PARENT_PATH}/plugins + diff --git a/srcs/requirements/nginx/Dockerfile b/srcs/requirements/nginx/Dockerfile index 9894f07..e6a6264 100644 --- a/srcs/requirements/nginx/Dockerfile +++ b/srcs/requirements/nginx/Dockerfile @@ -23,7 +23,7 @@ RUN adduser -S www-data && \ # ARG variables are not persistent after the build process, in opposite to ENV ARG WP_URL ARG WP_VOLUME_DIR -ARG NG_VOLUME_CERTS +ARG NG_CERTS_DIR ARG SERVER_MAX_UPLOAD_SIZE # replace WP_URL @@ -42,10 +42,10 @@ RUN sed -i "s/\(client_max_body_size \).*\(m;\)/\1${SERVER_MAX_UPLOAD_SIZE}\2/g" # - C, ST, L, O, OU, CN : country, state, locality, organization, organizational unit, and common name # - keyout : the filename for the private key file # - out : the filename for the output certificate file -ARG SSL_KEY=${NG_VOLUME_CERTS}/private/${WP_URL}.key -ARG SSL_CERT=${NG_VOLUME_CERTS}/certs/${WP_URL}.crt -RUN mkdir -p ${NG_VOLUME_CERTS}; \ - cd ${NG_VOLUME_CERTS}; \ +ARG SSL_KEY=${NG_CERTS_DIR}/private/${WP_URL}.key +ARG SSL_CERT=${NG_CERTS_DIR}/certs/${WP_URL}.crt +RUN mkdir -p ${NG_CERTS_DIR}; \ + cd ${NG_CERTS_DIR}; \ mkdir private certs; \ openssl req -newkey rsa:2048 -nodes -x509 -days 365 \ -subj "/C=fr/ST=ile-de-france/L=paris/O=wp/OU=wp_local/CN=${WP_URL}" \ diff --git a/srcs/requirements/wordpress/conf/wp_entrypoint.sh b/srcs/requirements/wordpress/conf/wp_entrypoint.sh index 6c0f30a..8632631 100644 --- a/srcs/requirements/wordpress/conf/wp_entrypoint.sh +++ b/srcs/requirements/wordpress/conf/wp_entrypoint.sh @@ -58,6 +58,12 @@ then chown -R www-data:www-data /var/www/* chmod 755 -R /var/www/* + echo -e ${YELLOW}plugins...${RESET} + plugins=$(ls ${WP_VOLUME_PLUGINS}) + for dir in $plugins; do + ln -s ${WP_VOLUME_PLUGINS}/$dir ${WP_VOLUME_DIR}/wp-content/plugins/$dir + done + echo -e ${GREEN}done !${RESET} else