diff --git a/Makefile b/Makefile index 6d93a95..b32e24a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ SRC_WWW_MORE=srcs/www/ .ONESHELL : .SHELLFLAGS = -eu -c -.PHONY : run install uninstall debug re help shell +.PHONY : run uninstall debug re help shell ### pretty logs #### @@ -23,7 +23,7 @@ _ECHO = echoo(){ \ ## Run the compose. -run : $(WWW_PATH) +run : @$(_ECHO) echoo "Running '$(SRC_COMPOSE)'..." @@ -31,31 +31,6 @@ run : $(WWW_PATH) INCEPTION_WWW_PATH="$(shell realpath $(WWW_PATH))" $(DOCKER) compose up --build -## Create WWW_PATH from wordpress' release. -install : $(WWW_PATH) - - -$(WWW_PATH) : - @$(_ECHO) - - echoo "Creating $(WWW_PATH) directory from wordpress release..." - - rm -rf $(BUILD_PATH) - - # download and uncompress release - mkdir -p $(BUILD_PATH)"/www/" - curl https://wordpress.org/latest.tar.gz | tar zx -C $(BUILD_PATH)/www - - # move in WWW_PATH - rm -rf -- $(WWW_PATH) - mv $(BUILD_PATH)"/www/wordpress" $(WWW_PATH) - echo - echo "also copy files from $(SRC_WWW_MORE)" - cp -r $(SRC_WWW_MORE)/. $(WWW_PATH) - - rm -rf $(BUILD_PATH) - - ## Remove WWW_PATH. uninstall : @$(_ECHO) @@ -66,10 +41,11 @@ uninstall : # TODO(ugly) -docker container prune -docker volume rm my-awesome-compose_db + -docker volume rm my-awesome-compose_www ## 'uninstall' then 'install' -re : uninstall install +re : uninstall run @$(_ECHO) echo echo "run \`make\` or \`make run\` to run the docker." @@ -90,9 +66,8 @@ help : echo echo "run Run the compose, install WWW_PATH if necessary." - echo "install Create WWW_PATH from wordpress' release." - echo "uninstall Remove WWW_PATH." - echo "re 'uninstall' then 'install'." + echo "uninstall TODO" + echo "re 'uninstall' then 'run'." # TODO docs shell echo echo "WWW_PATH is the volume directory where WordPress is installed." diff --git a/TODO b/TODO index 7392ecc..c17f091 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ TODO later - dependencies between containers and check if its is working -- volume www to normal volume, and create it in docker diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 1559459..ec35e7d 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -26,11 +26,6 @@ services: volumes: www: - driver: local - driver_opts: - o: bind - type: none - device: "${INCEPTION_WWW_PATH:?error}" db: ### services ### diff --git a/srcs/requirements/wordpress/Dockerfile b/srcs/requirements/wordpress/Dockerfile index 7eb1a7b..a1358a0 100644 --- a/srcs/requirements/wordpress/Dockerfile +++ b/srcs/requirements/wordpress/Dockerfile @@ -19,6 +19,8 @@ RUN adduser -D -S -G www www # add config COPY /conf/ /etc/php83/ +COPY /conf/wwwmore/ /conf/wwwmore/ +COPY /run.sh /run.sh # start -CMD ["php-fpm83", "-F"] +CMD ["/run.sh"] diff --git a/srcs/www/497.php b/srcs/requirements/wordpress/conf/wwwmore/497.php similarity index 100% rename from srcs/www/497.php rename to srcs/requirements/wordpress/conf/wwwmore/497.php diff --git a/srcs/www/wp-config.php b/srcs/requirements/wordpress/conf/wwwmore/wp-config.php similarity index 100% rename from srcs/www/wp-config.php rename to srcs/requirements/wordpress/conf/wwwmore/wp-config.php diff --git a/srcs/requirements/wordpress/run.sh b/srcs/requirements/wordpress/run.sh new file mode 100755 index 0000000..87345ce --- /dev/null +++ b/srcs/requirements/wordpress/run.sh @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +echo + +dirisempty() +{ + [ -z "$( ls -A "$1" )" ] +} + +if dirisempty /www +then + echo "download and uncompress wordpress release..." + echo + apk add curl + apk fix + rm -rf /build + mkdir -p "/build/www/" + curl https://wordpress.org/latest.tar.gz | tar zx -C /build/www + chmod -R 777 /www + mv $(find /build/www/wordpress -maxdepth 1 -mindepth 1) /www + rm -rf /build + echo + echo "add files from /conf/wwwmore/" + echo + cp -r /conf/wwwmore/. /www + echo "www directory created!" + echo +fi + +echo "to recreate the www directory, remove the www volume of this compose." +echo + +php-fpm83 -F