clean up details in makefile and model_env
This commit is contained in:
37
Makefile
37
Makefile
@@ -26,9 +26,9 @@ RESET := "\e[0m"
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
COMPOSE_FILE := ./srcs/docker-compose.yml
|
COMPOSE_FILE := ./srcs/docker-compose.yml
|
||||||
ENV_PATH := ./srcs/.env
|
|
||||||
|
|
||||||
# get env variables from .env file :
|
# get env variables from .env file :
|
||||||
|
ENV_PATH := ./srcs/.env
|
||||||
SOURCE_ENV := . $(ENV_PATH)
|
SOURCE_ENV := . $(ENV_PATH)
|
||||||
# list of volumes
|
# list of volumes
|
||||||
VOLUME_ENV := set | grep "^HOST_VOLUME_" | cut -d "=" -f 2
|
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 )
|
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
|
# 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -51,17 +51,19 @@ VOLUMES := $(shell docker volume ls -q)
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: require build up
|
all: require build up
|
||||||
logs: require build_logs up
|
logs: require build_logs up
|
||||||
|
|
||||||
require:
|
|
||||||
# create .env file
|
|
||||||
|
create_env:
|
||||||
@echo $(B_PURPLE)"create the .env file"$(RESET)
|
@echo $(B_PURPLE)"create the .env file"$(RESET)
|
||||||
./srcs/env_generator/create_env.sh ./srcs/model.env
|
./srcs/env_generator/create_env.sh ./srcs/model.env
|
||||||
# create the volumes directories
|
create_volumes_d:
|
||||||
@echo $(B_PURPLE)"create the volumes directories"$(RESET)
|
@echo $(B_PURPLE)"create the volumes directories"$(RESET)
|
||||||
mkdir -p $(VOLUMES_D)
|
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)
|
@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 \
|
-@ 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); \
|
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); \
|
echo $(B_GREEN)"it has been succesfully added :)"$(RESET); \
|
||||||
fi \
|
fi \
|
||||||
fi
|
fi
|
||||||
|
require: create_env create_volumes_d add_url_host
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker compose -f $(COMPOSE_FILE) build
|
docker compose -f $(COMPOSE_FILE) build
|
||||||
@@ -80,13 +85,16 @@ build:
|
|||||||
build_logs:
|
build_logs:
|
||||||
docker compose -f $(COMPOSE_FILE) build --progress plain --no-cache
|
docker compose -f $(COMPOSE_FILE) build --progress plain --no-cache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
up:
|
up:
|
||||||
docker compose -f $(COMPOSE_FILE) up -d
|
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)
|
@echo $(B_PURPLE)"you can now connect at "$(B_YELLOW)"https://$(WP_COMPLETE_URL)"$(B_PURPLE)" or 127.0.0.1"$(RESET)
|
||||||
|
|
||||||
down:
|
down:
|
||||||
docker compose -f $(COMPOSE_FILE) down
|
docker compose -f $(COMPOSE_FILE) down
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# list images, containers, volumes
|
# list images, containers, volumes
|
||||||
list:
|
list:
|
||||||
@echo $(B_YELLOW)"\nimages:"$(RESET)
|
@echo $(B_YELLOW)"\nimages:"$(RESET)
|
||||||
@@ -101,12 +109,13 @@ list:
|
|||||||
@docker ps -a
|
@docker ps -a
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# remove project images and containers not used
|
# remove project images and containers not used
|
||||||
clean:
|
clean:
|
||||||
- docker stop $(RUNNING)
|
- docker stop $(RUNNING)
|
||||||
docker network prune -f
|
docker network prune -f
|
||||||
docker system prune -f
|
docker system prune -f
|
||||||
|
|
||||||
# remove everything except local volumes data
|
# remove everything except local volumes data
|
||||||
fclean-images: clean
|
fclean-images: clean
|
||||||
- docker stop $(RUNNING)
|
- docker stop $(RUNNING)
|
||||||
@@ -114,14 +123,18 @@ fclean-images: clean
|
|||||||
fclean-volumes: clean
|
fclean-volumes: clean
|
||||||
- docker volume rm $(VOLUMES)
|
- docker volume rm $(VOLUMES)
|
||||||
fclean: fclean-images fclean-volumes
|
fclean: fclean-images fclean-volumes
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# !! remove everything everything
|
# !! remove everything everything
|
||||||
erase:
|
erase_volume:
|
||||||
|
- rm -rf $(VOLUMES_D)
|
||||||
|
erase: erase_volume fclean
|
||||||
- rm -rf $(VOLUMES_D)
|
- rm -rf $(VOLUMES_D)
|
||||||
$(MAKE) fclean
|
|
||||||
new: erase $(NAME)
|
new: erase $(NAME)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase new require
|
.PHONY : all $(VOLUMES_D) require build up list clean fclean re erase new require
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ PROJECT=jipf
|
|||||||
WP_ADMIN=admin
|
WP_ADMIN=admin
|
||||||
WP_ADMIN_EMAIL=admin@email.fr
|
WP_ADMIN_EMAIL=admin@email.fr
|
||||||
WP_ADMIN_PSWD='you shall not password !'
|
WP_ADMIN_PSWD='you shall not password !'
|
||||||
WP_COMPLETE_URL=local_lejourduprof.com:3003
|
WP_COMPLETE_URL=local_lejourduprof.com
|
||||||
WP_PORT=3003
|
WP_PORT=443
|
||||||
WP_TITLE=title
|
WP_TITLE=title
|
||||||
WP_URL=local_lejourduprof.com
|
WP_URL=local_lejourduprof.com
|
||||||
WP_VOLUME_DIR=/var/www/html
|
WP_VOLUME_DIR=/var/www/html
|
||||||
|
|||||||
@@ -1,22 +1,30 @@
|
|||||||
|
|
||||||
PROJECT=jipf
|
|
||||||
|
|
||||||
|
PROJECT_NAME="jipf"
|
||||||
|
PROJECT_URL="local_lejourduprof.com"
|
||||||
|
PROJECT_PORT=443
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
# NGINX SETUP
|
# NGINX SETUP
|
||||||
|
|
||||||
NG_VOLUME_CERTS=/etc/ssl
|
NG_VOLUME_CERTS=/etc/ssl
|
||||||
MAX_UPLOAD_SIZE=512
|
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
# MARIADB SETUP
|
# MARIADB SETUP
|
||||||
|
|
||||||
DB_HOST=mariadb
|
DB_HOST=mariadb
|
||||||
DB_NAME=db_wp_${PROJECT}
|
DB_NAME=db_wp_${PROJECT_NAME}
|
||||||
DB_USER=user_wp_${PROJECT}
|
DB_USER=user_wp_${PROJECT_NAME}
|
||||||
DB_PSWD="you dont want to know"
|
DB_PSWD="you dont want to know"
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
# WORDPRESS SETUP
|
# WORDPRESS SETUP
|
||||||
|
|
||||||
WP_URL=local_lejourduprof.com
|
WP_URL=${PROJECT_URL}
|
||||||
WP_PORT=3003
|
WP_PORT=${PROJECT_PORT}
|
||||||
# concat url with port if not 443
|
# concat url with port if not 443
|
||||||
WP_COMPLETE_URL="${WP_URL}"
|
WP_COMPLETE_URL="${WP_URL}"
|
||||||
if [ ! ${WP_PORT} -eq 443 ]; then
|
if [ ! ${WP_PORT} -eq 443 ]; then
|
||||||
@@ -25,14 +33,17 @@ fi
|
|||||||
WP_VOLUME_DIR=/var/www/html
|
WP_VOLUME_DIR=/var/www/html
|
||||||
#WP_VOLUME_PLUGINS=/home/www-data
|
#WP_VOLUME_PLUGINS=/home/www-data
|
||||||
WP_TITLE=title
|
WP_TITLE=title
|
||||||
|
|
||||||
WP_ADMIN=admin
|
WP_ADMIN=admin
|
||||||
WP_ADMIN_PSWD="you shall not password !"
|
WP_ADMIN_PSWD="you shall not password !"
|
||||||
WP_ADMIN_EMAIL=admin@email.fr
|
WP_ADMIN_EMAIL=admin@email.fr
|
||||||
|
|
||||||
# MAP
|
# change execution_time and max_upload_size in wordpress
|
||||||
|
|
||||||
EXECUTION_TIME=300
|
EXECUTION_TIME=300
|
||||||
|
MAX_UPLOAD_SIZE=512
|
||||||
|
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# VOLUMES
|
||||||
|
|
||||||
# if you want to get the home directory you can use $(HOME)
|
# 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 :
|
# however, this will not give the same result if you use sudo, ex :
|
||||||
|
|||||||
Reference in New Issue
Block a user