clean up details in makefile and model_env

This commit is contained in:
asus
2024-02-01 14:29:23 +01:00
parent fdba54cdb7
commit 4aa3a88ccc
4 changed files with 48 additions and 23 deletions

View File

@@ -26,9 +26,9 @@ RESET := "\e[0m"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
COMPOSE_FILE := ./srcs/docker-compose.yml
ENV_PATH := ./srcs/.env
# get env variables from .env file :
ENV_PATH := ./srcs/.env
SOURCE_ENV := . $(ENV_PATH)
# list of volumes
VOLUME_ENV := set | grep "^HOST_VOLUME_" | cut -d "=" -f 2
@@ -38,9 +38,9 @@ WP_URL = $(shell $(SOURCE_ENV) ; echo $$WP_URL )
WP_COMPLETE_URL = $(shell $(SOURCE_ENV) ; echo $$WP_COMPLETE_URL )
# 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
VOLUMES := $(shell docker volume ls -q)
VOLUMES = $(shell docker volume ls -q)
@@ -51,17 +51,19 @@ VOLUMES := $(shell docker volume ls -q)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
all: require build up
logs: require build_logs up
require:
# create .env file
create_env:
@echo $(B_PURPLE)"create the .env file"$(RESET)
./srcs/env_generator/create_env.sh ./srcs/model.env
# create the volumes directories
create_volumes_d:
@echo $(B_PURPLE)"create the volumes directories"$(RESET)
mkdir -p $(VOLUMES_D)
# verify if the wordpress url is added to the local path
add_url_host:
@echo $(B_PURPLE)"verify if the wordpress url is added to the local path"$(RESET)
-@ if ! awk "/127.0.0.1/ && /$(WP_URL)/" /etc/hosts 2> /dev/null; then \
echo $(B_PURPLE)"nop ! trying to add it (might need sudo)"$(RESET); \
@@ -72,6 +74,9 @@ require:
echo $(B_GREEN)"it has been succesfully added :)"$(RESET); \
fi \
fi
require: create_env create_volumes_d add_url_host
build:
docker compose -f $(COMPOSE_FILE) build
@@ -80,13 +85,16 @@ build:
build_logs:
docker compose -f $(COMPOSE_FILE) build --progress plain --no-cache
up:
docker compose -f $(COMPOSE_FILE) up -d
@echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_COMPLETE_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET)
down:
docker compose -f $(COMPOSE_FILE) down
# list images, containers, volumes
list:
@echo $(B_YELLOW)"\nimages:"$(RESET)
@@ -101,12 +109,13 @@ list:
@docker ps -a
@echo ""
# remove project images and containers not used
clean:
- docker stop $(RUNNING)
docker network prune -f
docker system prune -f
# remove everything except local volumes data
fclean-images: clean
- docker stop $(RUNNING)
@@ -114,14 +123,18 @@ fclean-images: clean
fclean-volumes: clean
- docker volume rm $(VOLUMES)
fclean: fclean-images fclean-volumes
re: fclean all
# !! remove everything everything
erase:
erase_volume:
- rm -rf $(VOLUMES_D)
erase: erase_volume fclean
- rm -rf $(VOLUMES_D)
$(MAKE) fclean
new: erase $(NAME)
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase new require

View File

@@ -1,3 +1,4 @@
# toc :
- 1. MAP

View File

@@ -12,8 +12,8 @@ PROJECT=jipf
WP_ADMIN=admin
WP_ADMIN_EMAIL=admin@email.fr
WP_ADMIN_PSWD='you shall not password !'
WP_COMPLETE_URL=local_lejourduprof.com:3003
WP_PORT=3003
WP_COMPLETE_URL=local_lejourduprof.com
WP_PORT=443
WP_TITLE=title
WP_URL=local_lejourduprof.com
WP_VOLUME_DIR=/var/www/html

View File

@@ -1,22 +1,30 @@
PROJECT=jipf
PROJECT_NAME="jipf"
PROJECT_URL="local_lejourduprof.com"
PROJECT_PORT=443
# ----------------------------------------------------------------------
# NGINX SETUP
NG_VOLUME_CERTS=/etc/ssl
MAX_UPLOAD_SIZE=512
# ----------------------------------------------------------------------
# MARIADB SETUP
DB_HOST=mariadb
DB_NAME=db_wp_${PROJECT}
DB_USER=user_wp_${PROJECT}
DB_NAME=db_wp_${PROJECT_NAME}
DB_USER=user_wp_${PROJECT_NAME}
DB_PSWD="you dont want to know"
# ----------------------------------------------------------------------
# WORDPRESS SETUP
WP_URL=local_lejourduprof.com
WP_PORT=3003
WP_URL=${PROJECT_URL}
WP_PORT=${PROJECT_PORT}
# concat url with port if not 443
WP_COMPLETE_URL="${WP_URL}"
if [ ! ${WP_PORT} -eq 443 ]; then
@@ -25,14 +33,17 @@ fi
WP_VOLUME_DIR=/var/www/html
#WP_VOLUME_PLUGINS=/home/www-data
WP_TITLE=title
WP_ADMIN=admin
WP_ADMIN_PSWD="you shall not password !"
WP_ADMIN_EMAIL=admin@email.fr
# MAP
# change execution_time and max_upload_size in wordpress
EXECUTION_TIME=300
MAX_UPLOAD_SIZE=512
# ----------------------------------------------------------------------
# VOLUMES
# if you want to get the home directory you can use $(HOME)
# however, this will not give the same result if you use sudo, ex :