Files
42_INT_13_inception/Makefile
2022-09-06 17:37:52 +02:00

108 lines
2.5 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
IMAGES = test \
nginx \
mariadb
HOME_D = $(shell echo $(HOME))
VOLUMES_D = $(VOLUMES:%=$(HOME_D)/%)
VOLUMES = v_wp_site \
v_wp_db
CONTAINERS = $(IMAGES:%=my%)
CONT = mytest
SUDO =
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# use 'make' to launch and relaunch the project #
# use 'make re' to relaunch and clean the dungling images #
# use 'make fre' to start all over again (images) #
# use 'make super-clean' if you want to delete all dockers on com- #
# puter even if not related to the project #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
all: build $(VOLUMES_D) up
$(VOLUMES_D):
mkdir -p $(VOLUMES_D)
build:
$(SUDO) docker-compose -f $(COMPOSE) build
up: $(VOLUMES_D)
$(SUDO) docker-compose -f $(COMPOSE) up -d
# list images, containers, volumes
list:
@echo $(B_YELLOW)"\nimages:"$(RESET)
@$(SUDO) docker images -a
@echo $(B_YELLOW)"\ncontainers:"$(RESET)
@$(SUDO) docker ps -a
@echo $(B_YELLOW)"\nvolumes:"$(RESET)
@$(SUDO) docker volume ls
@echo ""
# remove project images
rm-images:
$(SUDO) docker image rm -f $(IMAGES)
# stop project containers
stop:
- $(SUDO) docker stop $(CONTAINERS)
# remove all stopped containers and dangling images (dangling images, see : https://projectatomic.io/blog/2015/07/what-are-docker-none-none-images/)
prune:
$(SUDO) docker system prune -f
# remove project images and containers
clean: stop prune
# remove project volumes
rm-volumes:
- $(SUDO) docker volume rm -f $(VOLUMES)
/bin/rm -rf $(VOLUMES_D)
# remove project
fclean: rm-images clean rm-volumes
# remove all dockers, even not related to the project
super-clean:
- $(SUDO) docker stop $(sudo docker ps -q)
$(SUDO) docker system prune -af --volumes
/bin/rm -rf $(VOLUMES_D)
re: clean all
fre: fclean all
.PHONY : all build up $(VOLUMES_D) list rm-images stop rm-containers close-nginx prune clean rm-volumes fclean super-clean re fre