pulls out container.mk
This commit is contained in:
@@ -34,27 +34,40 @@ RESTART_NGINX := sudo rc-service nginx restart
|
|||||||
container_image_name = $(REGISTRY_DOMAIN)/$(REGISTRY_USER)/joeac.net-$(module)
|
container_image_name = $(REGISTRY_DOMAIN)/$(REGISTRY_USER)/joeac.net-$(module)
|
||||||
nginx_module_target = $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf)
|
nginx_module_target = $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf)
|
||||||
dyndns_module_target = $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net)
|
dyndns_module_target = $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net)
|
||||||
openrc_module_target = $(if $(filter $(COMPOSE_SERVICES),$(module)),~/.config/rc/init.d/joeac.net.$(module))
|
|
||||||
|
|
||||||
|
define install_module_rule =
|
||||||
|
.PHONY: install_$(module)
|
||||||
|
install_$(module): install_openrc_$(module) $(nginx_module_target) $(dyndns_module_target) $(install_submake_file)
|
||||||
|
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) install)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define reinstall_module_rule =
|
||||||
|
.PHONY: reinstall_$(module)
|
||||||
|
reinstall_$(module): reinstall_openrc_$(module) $(nginx_module_target) $(dyndns_module_target) $(install_submake_file)
|
||||||
|
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) reinstall)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define uninstall_module_rule =
|
||||||
|
.PHONY: uninstall_$(module)
|
||||||
|
uninstall_$(module):
|
||||||
|
$(if $(openrc_module_target),\
|
||||||
|
rc-service -U joeac.net.$(module) stop \
|
||||||
|
rc-update -U del joeac.net.$(module) default \
|
||||||
|
rm ~/.config/rc/init.d/joeac.net.$(module) \
|
||||||
|
)
|
||||||
|
$(if $(SUBDOMAIN_$(module)),\
|
||||||
|
sudo rm -f /etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf; \
|
||||||
|
$(RESTART_NGINX); \
|
||||||
|
sudo rm -f /etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net; \
|
||||||
|
)
|
||||||
|
$(if $(install_submake_file),\
|
||||||
|
$(MAKE) --makefile=$(notdir (install_submake_file)) --directory $(dir $(install_submake_file)) uninstall
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
= $(if $(filter $(COMPOSE_SERVICES),$(module)),~/.config/rc/init.d/joeac.net.$(module))
|
||||||
install_submake_file = $(shell [ -f "$(module)/install.mk" ] && echo "$(module)/install.mk")
|
install_submake_file = $(shell [ -f "$(module)/install.mk" ] && echo "$(module)/install.mk")
|
||||||
|
|
||||||
define build_module_rule =
|
|
||||||
.PHONY: build_$(module)
|
|
||||||
build_$(module): make_$(module) $(module).Dockerfile
|
|
||||||
podman-compose build $(module)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define push_module_rule =
|
|
||||||
.PHONY: push_$(module)
|
|
||||||
push_$(module): login_registry build_$(module)
|
|
||||||
podman push $(container_image_name)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define make_module_rule =
|
|
||||||
.PHONY: make_$(module)
|
|
||||||
make_$(module): $(module)/.env
|
|
||||||
$(MAKE) --directory=$(module)
|
|
||||||
endef
|
|
||||||
|
|
||||||
define module_env_rule =
|
define module_env_rule =
|
||||||
$(module)/.env: .env
|
$(module)/.env: .env
|
||||||
cp .env $(module)/.env
|
cp .env $(module)/.env
|
||||||
@@ -106,15 +119,8 @@ usage:
|
|||||||
echo " make uninstall"
|
echo " make uninstall"
|
||||||
$(foreach module,$(MODULES),echo " make uninstall_$(module)")
|
$(foreach module,$(MODULES),echo " make uninstall_$(module)")
|
||||||
|
|
||||||
$(foreach module,$(COMPOSE_SERVICES),$(eval $(call build_module_rule)))
|
|
||||||
$(foreach module,$(COMPOSE_SERVICES),$(eval $(call push_module_rule)))
|
|
||||||
$(foreach module,$(MAKE_MODULES),$(eval $(call make_module_rule)))
|
|
||||||
$(foreach module,$(MODULES),$(eval $(call module_env_rule)))
|
$(foreach module,$(MODULES),$(eval $(call module_env_rule)))
|
||||||
|
|
||||||
.PHONY: login_registry
|
|
||||||
login_registry:
|
|
||||||
podman login $(REGISTRY_DOMAIN)
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: $(foreach module,$(MODULES),install_$(module)) install_crontab
|
install: $(foreach module,$(MODULES),install_$(module)) install_crontab
|
||||||
|
|
||||||
@@ -128,6 +134,7 @@ $(foreach module,$(MODULES),$(eval $(install_module_rule)))
|
|||||||
$(foreach module,$(MODULES),$(eval $(reinstall_module_rule)))
|
$(foreach module,$(MODULES),$(eval $(reinstall_module_rule)))
|
||||||
$(foreach module,$(MODULES),$(eval $(uninstall_module_rule)))
|
$(foreach module,$(MODULES),$(eval $(uninstall_module_rule)))
|
||||||
|
|
||||||
|
include container.mk
|
||||||
include openrc.mk
|
include openrc.mk
|
||||||
include nginx.mk
|
include nginx.mk
|
||||||
include crontab.mk
|
include crontab.mk
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
define build_module_rule =
|
||||||
|
.PHONY: build_$(module)
|
||||||
|
build_$(module): make_$(module) $(module).Dockerfile
|
||||||
|
podman-compose build $(module)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define push_module_rule =
|
||||||
|
.PHONY: push_$(module)
|
||||||
|
push_$(module): login_registry build_$(module)
|
||||||
|
podman push $(container_image_name)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define make_module_rule =
|
||||||
|
.PHONY: make_$(module)
|
||||||
|
make_$(module): $(module)/.env
|
||||||
|
$(MAKE) --directory=$(module)
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach module,$(COMPOSE_SERVICES),$(eval $(call build_module_rule)))
|
||||||
|
$(foreach module,$(COMPOSE_SERVICES),$(eval $(call push_module_rule)))
|
||||||
|
$(foreach module,$(MAKE_MODULES),$(eval $(call make_module_rule)))
|
||||||
|
|
||||||
|
.PHONY: login_registry
|
||||||
|
login_registry:
|
||||||
|
podman login $(REGISTRY_DOMAIN)
|
||||||
Reference in New Issue
Block a user