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
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user