fixed an error with path to volumes
This commit is contained in:
55
Makefile
55
Makefile
@@ -22,30 +22,61 @@ RESET = "\e[0m"
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
COMPOSE = ./srcs/docker-compose.yml
|
COMPOSE = ./srcs/docker-compose.yml
|
||||||
|
|
||||||
VOLUMES_D = $(shell grep "^HOST_VOLUME" ./srcs/.env | cut -d "=" -f 2)
|
# extract env variables in .env file
|
||||||
|
# then expend the home path
|
||||||
|
# then expend the pwd path
|
||||||
|
# and finally remove the leading "EXPEND_" word
|
||||||
|
EXPENDED_ENV_VAR := $(shell grep "^EXPEND_" ./srcs/.env)
|
||||||
|
EXPENDED_ENV_VAR := $(subst $$HOME_PATH,$(HOME),$(EXPENDED_ENV_VAR))
|
||||||
|
EXPENDED_ENV_VAR := $(subst $$PWD_PATH,$(shell pwd),$(EXPENDED_ENV_VAR))
|
||||||
|
EXPENDED_ENV_VAR := $(EXPENDED_ENV_VAR:EXPEND_%=%)
|
||||||
|
|
||||||
WP_URL = $(shell grep "WP_URL" ./srcs/.env | cut -d "=" -f 2)
|
# this creates a list of the path from the list of the variables :
|
||||||
|
# VAR_1=/path/to_1 VAR_2=/path/to_2
|
||||||
|
# becomes :
|
||||||
|
# /path/to_1 /path/to_2
|
||||||
|
# first, foreach execute an action on each space separated parts : the variables
|
||||||
|
# - VAR_1=/path/to_1
|
||||||
|
# - VAR_2=/path/to_2
|
||||||
|
# then on each of them, it substitute the "=" with a space " " :
|
||||||
|
# - VAR_1 /path/to_1
|
||||||
|
# - VAR_2 /path/to_2
|
||||||
|
# and it only keeps the second word :
|
||||||
|
# - /path/to_1
|
||||||
|
# - /path/to_2
|
||||||
|
VOLUMES_D = $(foreach val,$(EXPENDED_ENV_VAR),$(word 2, $(subst =, ,$(val))))
|
||||||
|
|
||||||
|
# url for wordpress, use in makefile to change local
|
||||||
|
WP_URL = $(shell grep "WP_URL" ./srcs/.env | cut -d "=" -f 2)
|
||||||
|
|
||||||
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
|
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
|
||||||
RUNNING = $(shell docker ps -q)
|
RUNNING = $(shell docker ps -q)
|
||||||
# list of volumes
|
# list of volumes
|
||||||
VOLUMES = $(shell docker volume ls -q)
|
VOLUMES = $(shell docker volume ls -q)
|
||||||
|
|
||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
all: volumes build up
|
all: require build up
|
||||||
|
|
||||||
volumes:
|
require:
|
||||||
|
# remove all the lines starting with "HOST_VOLUME_" in .env
|
||||||
|
@sed -i "/^HOST_VOLUME_/d" ./srcs/.env
|
||||||
|
# add new expended lines starting with "HOST_VOLUME_" after the line "# EXPENDED LINES :" in .env
|
||||||
|
@$(foreach val,$(EXPENDED_ENV_VAR),sed -i "/^# EXPENDED LINES/a\$(val)" ./srcs/.env;)
|
||||||
|
# create the volumes directories
|
||||||
mkdir -p $(VOLUMES_D)
|
mkdir -p $(VOLUMES_D)
|
||||||
|
# create the ssl folder to avoid pbm at nginx docker creation
|
||||||
|
mkdir -p ./srcs/requirements/nginx/conf/ssl
|
||||||
|
# verify if the wordpress url is added to the local path
|
||||||
|
- if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \
|
||||||
|
bash -c 'echo -e "\n# adding for lejourduprof (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \
|
||||||
|
fi
|
||||||
|
|
||||||
build:
|
build:
|
||||||
- if ! grep "127.0.0.1 $(WP_URL)" /etc/hosts 2> /dev/null; then \
|
|
||||||
bash -c 'echo -e "\n# adding for inception (you can delete it)\n127.0.0.1 $(WP_URL)" >> /etc/hosts'; \
|
|
||||||
fi
|
|
||||||
mkdir -p ./srcs/requirements/nginx/conf/ssl
|
|
||||||
docker compose -f $(COMPOSE) build
|
docker compose -f $(COMPOSE) build
|
||||||
|
|
||||||
up:
|
up:
|
||||||
@@ -89,5 +120,5 @@ erase_v:
|
|||||||
- rm -rf $(VOLUMES_D)
|
- rm -rf $(VOLUMES_D)
|
||||||
new: erase_v re
|
new: erase_v re
|
||||||
|
|
||||||
.PHONY : all $(VOLUMES_D) build up list clean fclean re erase_v new
|
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase_v new
|
||||||
|
|
||||||
|
|||||||
26
README.md
26
README.md
@@ -40,14 +40,36 @@
|
|||||||
- len: 1h30
|
- len: 1h30
|
||||||
- total: 3h
|
- total: 3h
|
||||||
- tarif: 90€
|
- tarif: 90€
|
||||||
|
|
||||||
- 09/09/23
|
- 09/09/23
|
||||||
- begin: 16h30
|
- begin: 16h30
|
||||||
- mes: "copying wp site"
|
- mes: "trying to copy wp site"
|
||||||
- end: 17h30
|
- end: 17h30
|
||||||
- len: 1h
|
- len: 1h
|
||||||
- total: 1h
|
- total: 1h
|
||||||
- tarif: 30€
|
- tarif: 30€
|
||||||
|
|
||||||
|
- 10/09/23
|
||||||
|
- begin: 10h
|
||||||
|
- mes: "trying to fix makefile and .env volume variable"
|
||||||
|
- end: 12h
|
||||||
|
- len: 2h
|
||||||
|
- total: 2h
|
||||||
|
- tarif: 60€
|
||||||
|
|
||||||
|
- 11/09/23
|
||||||
|
- begin: 10h
|
||||||
|
- mes: "fixed volume variable"
|
||||||
|
- end: 13h30
|
||||||
|
- len: 3h30
|
||||||
|
- begin: 14h
|
||||||
|
- mes: "copy site"
|
||||||
|
- end: h
|
||||||
|
- len: h
|
||||||
|
- total: h
|
||||||
|
- tarif: €
|
||||||
|
|
||||||
|
#### total : 90 + 30 = 120€
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
24
srcs/.env
24
srcs/.env
@@ -30,10 +30,24 @@ WP_USER_EMAIL=moehu36@42.fr
|
|||||||
MAX_UPLOAD_SIZE=512
|
MAX_UPLOAD_SIZE=512
|
||||||
EXECUTION_TIME=300
|
EXECUTION_TIME=300
|
||||||
|
|
||||||
# HOST (start with "HOST_VOLUME" for makefile)
|
# env file does not have expension capacity, so we simulate it with makefile :
|
||||||
|
# 1. the lines starting with EXPEND_ will be retrieved by the makefil
|
||||||
|
# 2. then it will expend the $HOME_PATH and $PWD_PATH
|
||||||
|
# 3. then it will remove the leading "EXPEND_" word
|
||||||
|
# 4. then it will erase all the line starting with "HOST_VOLUME_"
|
||||||
|
# 5. and finally it will add the expended lines after the line "EXPENDED LINES :"
|
||||||
|
|
||||||
HOST_VOLUME_WP=/home/lenovo/data/lejourduprof/wp_volume
|
EXPEND_HOST_VOLUME_WP=$HOME_PATH/data/lejourduprof/wp_volume
|
||||||
HOST_VOLUME_DB=/home/lenovo/data/lejourduprof/db_volume
|
EXPEND_HOST_VOLUME_DB=$HOME_PATH/data/lejourduprof/db_volume
|
||||||
HOST_VOLUME_PLUGINS=/home/lenovo/42/lejourduprof/srcs/plugins
|
EXPEND_HOST_VOLUME_PLUGINS=$PWD_PATH/srcs/plugins
|
||||||
HOST_VOLUME_CERTS=/home/lenovo/42/lejourduprof/srcs/requirements/nginx/conf/ssl
|
EXPEND_HOST_VOLUME_CERTS=$PWD_PATH/srcs/requirements/nginx/conf/ssl
|
||||||
|
# EXPENDED LINES :
|
||||||
|
HOST_VOLUME_CERTS=/home/asususus/Nextcloud/informatique/lejourduprof/srcs/requirements/nginx/conf/ssl
|
||||||
|
HOST_VOLUME_PLUGINS=/home/asususus/Nextcloud/informatique/lejourduprof/srcs/plugins
|
||||||
|
HOST_VOLUME_DB=/home/asususus/data/lejourduprof/db_volume
|
||||||
|
HOST_VOLUME_WP=/home/asususus/data/lejourduprof/wp_volume
|
||||||
|
|
||||||
|
#HOST_VOLUME_WP=/home/lenovo/data/lejourduprof/wp_volume
|
||||||
|
#HOST_VOLUME_DB=/home/lenovo/data/lejourduprof/db_volume
|
||||||
|
#HOST_VOLUME_PLUGINS=/home/lenovo/42/lejourduprof/srcs/plugins
|
||||||
|
#HOST_VOLUME_CERTS=/home/lenovo/42/lejourduprof/srcs/requirements/nginx/conf/ssl
|
||||||
|
|||||||
Reference in New Issue
Block a user