Last active
April 23, 2019 16:39
-
-
Save koaps/73c71a0c00c3b633f0e5911cc5140536 to your computer and use it in GitHub Desktop.
Local Dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALL_ACTIONS := build up down clean | |
ALL_TARGETS := proxy | |
DO_A := $(filter $(ALL_ACTIONS),$(MAKECMDGOALS)) | |
DO_T := $(filter $(ALL_TARGETS),$(MAKECMDGOALS)) | |
.DEFAULT_GOAL := all | |
actions := $(strip $(if $(DO_A), $(DO_A), up)) | |
targets := $(strip $(if $(DO_T), $(DO_T), $(ALL_TARGETS))) | |
define name-target | |
.$(strip $2)_$(strip $1) | |
endef | |
define add-target | |
$(1) += $(call name-target, $(1), $(2)) | |
endef | |
define do-target | |
$(1): $(2) | |
endef | |
# make targets | |
$(foreach t,$(targets),$(foreach a,$(actions),$(eval $(call add-target, $(t), $(a)) ))) | |
$(foreach t,$(targets),$(eval $(call do-target, $(t), $($t)) )) | |
# docker control | |
define .dc_clean | |
docker_cleanup && \ | |
docker network prune -f && \ | |
docker volume prune -f | |
endef | |
define .dc_down | |
cd $(1) && \ | |
docker-compose down -v | |
endef | |
define .dc_build | |
cd $(1) && \ | |
docker-compose build | |
endef | |
define .dc_pull | |
cd $(1) && \ | |
docker-compose pull | |
endef | |
define .dc_up | |
cd $(1) && \ | |
docker-compose up --force-recreate -d | |
endef | |
## all target | |
.PHONY: all | |
all: $(ALL_TARGETS) | |
## clean target | |
.PHONY: clean | |
clean: | |
$(call .dc_clean) | |
.down_proxy: | |
$(call .dc_down, dev_proxy) | |
.up_proxy: | |
$(call .dc_up, dev_proxy) | |
%: | |
@: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment