change: www volume managed better

This commit is contained in:
mcolonna 2025-06-13 12:26:40 +02:00
parent 49a136c709
commit f5c5b31fbd
7 changed files with 43 additions and 38 deletions

View file

@ -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."

1
TODO
View file

@ -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

View file

@ -26,11 +26,6 @@ services:
volumes:
www:
driver: local
driver_opts:
o: bind
type: none
device: "${INCEPTION_WWW_PATH:?error}"
db:
### services ###

View file

@ -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"]

View file

@ -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