Files
2023_WEBSITE_jipf/Makefile
asus dbf2e27d89 - suppress docs/
- clean up and modify readme
- launch docker
2023-09-03 16:39:41 +02:00

89 lines
2.1 KiB
Makefile

GRAY = "\e[0;30m"
RED = "\e[0;31m"
GREEN = "\e[0;32m"
YELLOW = "\e[0;33m"
BLUE = "\e[0;34m"
PURPLE = "\e[0;35m"
CYAN = "\e[0;36m"
WHITE = "\e[0;37m"
B_GRAY = "\e[1;30m"
B_RED = "\e[1;31m"
B_GREEN = "\e[1;32m"
B_YELLOW = "\e[1;33m"
B_BLUE = "\e[1;34m"
B_PURPLE = "\e[1;35m"
B_CYAN = "\e[1;36m"
B_WHITE = "\e[1;37m"
RESET = "\e[0m"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
COMPOSE = ./srcs/docker-compose.yml
VOLUMES_D = $(shell grep "^HOST_VOLUME" ./srcs/.env | cut -d "=" -f 2)
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
RUNNING = $(shell docker ps -q)
# list of volumes
VOLUMES = $(shell docker volume ls -q)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
all: volumes build up
volumes:
mkdir -p $(VOLUMES_D)
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
docker compose -f $(COMPOSE) build
up:
docker compose -f $(COMPOSE) up -d
down:
docker compose -f $(COMPOSE) down
# list images, containers, volumes
list:
@echo $(B_YELLOW)"\nimages:"$(RESET)
@docker images -a
@echo $(B_YELLOW)"\nvolumes:"$(RESET)
@docker volume ls
@echo $(B_YELLOW)"\nvolumes content:"$(RESET)
- @ls $(VOLUMES_D)
@echo $(B_YELLOW)"\nnetworks:"$(RESET)
@docker network ls
@echo $(B_YELLOW)"\ncontainers:"$(RESET)
@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)
docker system prune -af
fclean-volumes: clean
- docker volume rm $(VOLUMES)
fclean: fclean-images fclean-volumes
re: fclean all
.PHONY : all $(VOLUMES_D) build up list clean fclean re