mariadb and nginx works both with debian and alpine

+ makefile a little clean up
This commit is contained in:
hugo gogo
2022-09-18 16:39:13 +02:00
parent 5d01ad0fdc
commit 9708715bb5
9 changed files with 134 additions and 67 deletions

View File

@@ -24,32 +24,17 @@ RESET = "\e[0m"
COMPOSE = ./srcs/docker-compose.yml
IMAGES = nginx \
mariadb \
wordpress
HOME_D = $(shell echo $(HOME))
VOLUMES_D = $(VOLUMES:%=$(HOME_D)/%)
VOLUMES = v_wp_site \
v_wp_db
CONTAINERS = $(IMAGES:%=my%)
CONT = mytest
SUDO =
# for rule super-clean, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
STOP = $(shell $(SUDO) docker ps -q)
# list of running containers, see : https://stackoverflow.com/questions/10024279/how-to-use-shell-commands-in-makefile
RUNNING = $(shell $(SUDO) docker ps -q)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# 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
@@ -73,38 +58,18 @@ list:
@$(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:
# remove project images and containers not used
clean:
- $(SUDO) docker stop $(RUNNING)
$(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 $(STOP)
# remove every dockers
fclean:
- $(SUDO) docker stop $(RUNNING)
$(SUDO) docker system prune -af --volumes
/bin/rm -rf $(VOLUMES_D)
re: clean all
re: fclean 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
.PHONY : all $(VOLUMES_D) build up list clean fclean re