From 3bdcd4d4598ce8fba4b064de68539b5a2434851b Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Sun, 19 Jan 2025 15:20:16 +0100 Subject: [PATCH] Update makefile template Signed-off-by: Bensuperpc --- DockerCompose.mk | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 76 +++---------------------------------------- 2 files changed, 90 insertions(+), 71 deletions(-) create mode 100644 DockerCompose.mk diff --git a/DockerCompose.mk b/DockerCompose.mk new file mode 100644 index 0000000..40cf766 --- /dev/null +++ b/DockerCompose.mk @@ -0,0 +1,85 @@ +#////////////////////////////////////////////////////////////// +#// // +#// docker-multimedia, 2024 // +#// Created: 30, May, 2021 // +#// Modified: 14 November, 2024 // +#// file: - // +#// - // +#// Source: // +#// OS: ALL // +#// CPU: ALL // +#// // +#////////////////////////////////////////////////////////////// + +PROJECT_DIRECTORY ?= infrastructure + +DOCKER_EXEC ?= docker + +DOCKER_PROFILES ?= main_infrastructure + +PROFILE_CMD ?= $(addprefix --profile ,$(DOCKER_PROFILES)) + +COMPOSE_FILES ?= $(shell find ./$(PROJECT_DIRECTORY) -name 'docker-compose*.yml' -type f | sed -e 's/^/--file /') +COMPOSE_DIR ?= --project-directory ./$(PROJECT_DIRECTORY) + +UID ?= 1000 +GID ?= 1000 + +ENV_ARG_VAR ?= PUID=$(UID) PGID=$(GID) + +DOCKER_COMPOSE_COMMAND ?= $(ENV_ARG_VAR) $(DOCKER_EXEC) compose $(COMPOSE_DIR) $(COMPOSE_FILES) $(PROFILE_CMD) + +.PHONY: build all +all: start + +.PHONY: build +build: + $(DOCKER_COMPOSE_COMMAND) build + +.PHONY: start +start: + $(DOCKER_COMPOSE_COMMAND) up -d + +.PHONY: start-at +start-at: + $(DOCKER_COMPOSE_COMMAND) up + +.PHONY: docker-check +docker-check: + $(DOCKER_COMPOSE_COMMAND) config + +.PHONY: stop +stop: down + +.PHONY: down +down: + $(DOCKER_COMPOSE_COMMAND) down + +.PHONY: restart +restart: stop start + +.PHONY: logs +logs: + $(DOCKER_COMPOSE_COMMAND) logs + +.PHONY: state +state: + $(DOCKER_COMPOSE_COMMAND) ps + $(DOCKER_COMPOSE_COMMAND) top + +.PHONY: update-docker +update-docker: + $(DOCKER_COMPOSE_COMMAND) pull + +.PHONY: update +update: update-docker +# git submodule update --init --recursive --remote + git pull --recurse-submodules --all --progress + +.PHONY: clean +clean: + docker system prune -f + +.PHONY: purge +purge: + $(ENV_ARG_VAR) $(DOCKER_EXEC) compose $(COMPOSE_DIR) $(COMPOSE_FILES) down -v --rmi all diff --git a/Makefile b/Makefile index 9c69c55..1c333a8 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ #////////////////////////////////////////////////////////////// #// // -#// Infrastructure, 2024 // +#// Script, 2022 // #// Created: 14, April, 2022 // -#// Modified: 05, May, 2024 // +#// Modified: 30, November, 2024 // #// file: - // #// - // #// Source: // @@ -11,10 +11,6 @@ #// // #////////////////////////////////////////////////////////////// -SERVER_DIRECTORY := infrastructure - -DOCKER := docker - BLOG_SERVICES := wordpress TORRENTS_SERVICES := qbittorrent transmission SHARING_SERVICES := psitransfer picoshare privatebin projectsend jellyfin dufs gitea syncthing @@ -22,70 +18,8 @@ ADMIN_SERVICES := yacht uptime-kuma adminer openssh UTILS_SERVICES := it-tools stirlingpdf # gitea-runner -PROFILES := main_infrastructure caddy homepage $(BLOG_SERVICES) $(SHARING_SERVICES) $(TORRENTS_SERVICES) $(ADMIN_SERVICES) $(UTILS_SERVICES) -PROFILE_CMD := $(addprefix --profile ,$(PROFILES)) +SERVER_DIRECTORY := infrastructure -COMPOSE_FILES := $(shell find ./$(SERVER_DIRECTORY) -name 'docker-compose*.yml' -type f | sed -e 's/^/--file /') -COMPOSE_DIR := --project-directory ./$(SERVER_DIRECTORY) +DOCKER_PROFILES := main_infrastructure caddy homepage $(BLOG_SERVICES) $(SHARING_SERVICES) $(TORRENTS_SERVICES) $(ADMIN_SERVICES) $(UTILS_SERVICES) -UID := 1000 -GID := 1000 - -ENV_ARG_VAR := PUID=$(UID) PGID=$(GID) - -DOCKER_COMPOSE_COMMAND := $(ENV_ARG_VAR) $(DOCKER) compose $(COMPOSE_DIR) $(COMPOSE_FILES) $(PROFILE_CMD) - -.PHONY: build all -all: start - -.PHONY: build -build: - $(DOCKER_COMPOSE_COMMAND) build - -.PHONY: start -start: - $(DOCKER_COMPOSE_COMMAND) up -d - -.PHONY: start-at -start-at: - $(DOCKER_COMPOSE_COMMAND) up - -.PHONY: docker-check -docker-check: - $(DOCKER_COMPOSE_COMMAND) config - -.PHONY: stop -stop: down - -.PHONY: down -down: - $(DOCKER_COMPOSE_COMMAND) down - -.PHONY: restart -restart: stop start - -.PHONY: logs -logs: - $(DOCKER_COMPOSE_COMMAND) logs - -.PHONY: state -state: - $(DOCKER_COMPOSE_COMMAND) ps - $(DOCKER_COMPOSE_COMMAND) top - -.PHONY: update-docker -update-docker: - $(DOCKER_COMPOSE_COMMAND) pull - -.PHONY: update -update: update-docker - git submodule update --init --recursive --remote - git pull --recurse-submodules --all --progress - -.PHONY: clean -clean: - docker system prune -f - -.PHONY: purge -purge: - $(ENV_ARG_VAR) $(DOCKER) compose $(COMPOSE_DIR) $(COMPOSE_FILES) down -v --rmi all \ No newline at end of file +include DockerCompose.mk