inception/Makefile

96 lines
1.9 KiB
Makefile

# TODO(vm) data is supposed to be in $HOME/data/
WWW_PATH=__www/ # TODO to change
BUILD_PATH=__build/
DOCKER=docker
SRC_COMPOSE=srcs/
SRC_WWW_MORE=srcs/www/
.ONESHELL :
.SHELLFLAGS = -eu -c
.PHONY : run install uninstall debug re help shell
### pretty logs ####
_ECHO = echoo(){ \
if [ -t 1 ]; then \
echo "\e[30;47;1m$$*\e[0m"; \
else \
echo "$$*"; \
fi; \
}
## Run the compose.
run : $(WWW_PATH)
@$(_ECHO)
echoo "Running '$(SRC_COMPOSE)'..."
cd -- $(SRC_COMPOSE)
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)
echoo "Removing $(WWW_PATH)..."
rm -r $(WWW_PATH) || true
## 'uninstall' then 'install'
re : uninstall install
@$(_ECHO)
echo
echo "run \`make\` or \`make run\` to run the docker."
## TODO docs
shell :
@$(_ECHO)
echoo "Running shell inside '$(SRC_COMPOSE)' (container nginx)..."
cd -- $(SRC_COMPOSE)
INCEPTION_WWW_PATH="$(shell realpath $(WWW_PATH))" $(DOCKER) compose run --build nginx sh
## Show help
help :
@$(_ECHO)
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'."
# TODO docs shell
echo
echo "WWW_PATH is the volume directory where WordPress is installed."
echo "you might want to reset the WWW_PATH variable in the Makefile."
echo