external app
This commit is contained in:
+90
-27
@@ -1,3 +1,5 @@
|
||||
CMDARGS += app-%-exec app-%-run
|
||||
|
||||
# function app-bootstrap: Define custom variables for app 1 in dir 2 with name 3 and type 4
|
||||
define app-bootstrap
|
||||
$(call INFO,app-bootstrap,$(1)$(comma) $(2$(comma) $(3))$(comma) $(4))
|
||||
@@ -18,7 +20,7 @@ endef
|
||||
|
||||
# function app-build: Call docker-build for each Dockerfile in dir 1
|
||||
define app-build
|
||||
$(call INFO,app-build,$(1))
|
||||
$(call INFO,app-build,$(1)$(comma))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
@@ -27,13 +29,13 @@ define app-build
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(call docker-build, $(dir $(dockerfile)), $(DOCKER_IMAGE), "" )
|
||||
),
|
||||
$(call ERROR,Unable to find any Dockerfile in dir: $(or $(1),$(APP_DIR)))
|
||||
$(call ERROR,Unable to find a,Dockerfile in dir,$(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-docker: Define custom variables for Dockerfile 1
|
||||
define app-docker
|
||||
$(call INFO,app-docker,$(1))
|
||||
$(call INFO,app-docker,$(1)$(comma))
|
||||
$(eval dir := $(or $(APP_DIR)))
|
||||
$(eval dockerfile := $(or $(1)))
|
||||
$(if $(wildcard $(dockerfile)),
|
||||
@@ -44,26 +46,64 @@ define app-docker
|
||||
$(eval DOCKER_NAME := $(docker))
|
||||
$(eval DOCKER_RUN_NAME := --name $(DOCKER_NAME))
|
||||
,
|
||||
$(call ERROR,Unable to find Dockerfile: $(dockerfile))
|
||||
$(call ERROR,Unable to find Dockerfile,$(dockerfile))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-connect: Call docker exec $(DOCKER_SHELL) for each Dockerfile in dir 1
|
||||
define app-connect
|
||||
$(call INFO,app-connect,$(1)$(comma))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(if $(DOCKER_FILE),
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(RUN) docker exec -it $(DOCKER_NAME) $(DOCKER_SHELL)
|
||||
,
|
||||
$(call WARNING,Unable to find docker,$(DOCKER_NAME))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find a,Dockerfile,in dir $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-down: Call docker rm for each Dockerfile in dir 1
|
||||
define app-down
|
||||
$(call INFO,app-down,$(1))
|
||||
$(call INFO,app-down,$(1)$(comma))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(if $(DOCKER_FILE), \
|
||||
$(if $(DOCKER_FILE),
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(shell docker rm -f $(DOCKER_NAME))
|
||||
$(RUN) docker rm -f $(DOCKER_NAME)
|
||||
,
|
||||
$(call ERROR,Unable to find docker $(DOCKER_NAME))
|
||||
$(call WARNING,Unable to find docker,$(DOCKER_NAME))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find any Dockerfile in dir: $(or $(1),$(APP_DIR)))
|
||||
$(call ERROR,Unable to find a,Dockerfile,in dir $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-exec: Call docker exec $(ARGS) for each Dockerfile in dir 1
|
||||
define app-exec
|
||||
$(call INFO,app-exec,$(1)$(comma) $(2))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(if $(DOCKER_FILE),
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(RUN) docker exec -it $(DOCKER_NAME) $(ARGS)
|
||||
,
|
||||
$(call WARNING,Unable to find docker,$(DOCKER_NAME))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find a,Dockerfile,in dir $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
@@ -78,9 +118,45 @@ define app-install
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-logs: Call docker logs $(ARGS) for each Dockerfile in dir 1
|
||||
define app-logs
|
||||
$(call INFO,app-logs,$(1)$(comma) $(2))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(if $(DOCKER_FILE),
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker ps -q -f name=$(DOCKER_NAME) 2>/dev/null),
|
||||
$(RUN) docker logs --follow --tail=100 $(DOCKER_NAME)
|
||||
,
|
||||
$(call WARNING,Unable to find docker,$(DOCKER_NAME))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find a,Dockerfile,in dir $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-ps: Call docker ps $(ARGS) for each Dockerfile in dir 1
|
||||
define app-ps
|
||||
$(call INFO,app-ps,$(1)$(comma) $(2))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(if $(DOCKER_FILE),
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(eval DOCKERS += $(DOCKER_NAME))
|
||||
)
|
||||
$(RUN) docker ps $(patsubst %,-f name=%,$(DOCKERS)) 2>/dev/null
|
||||
,
|
||||
$(call ERROR,Unable to find a,Dockerfile,in dir $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-rebuild: Call app-build with DOCKER_BUILD_CACHE=false
|
||||
define app-rebuild
|
||||
$(call INFO,app-rebuild,$(1))
|
||||
$(call INFO,app-rebuild,$(1)$(comma))
|
||||
$(eval DOCKER_BUILD_CACHE := false)
|
||||
$(call app-build,$(1))
|
||||
endef
|
||||
@@ -99,31 +175,18 @@ define app-run
|
||||
$(if $(shell docker images -q $(DOCKER_IMAGE) 2>/dev/null),
|
||||
$(call docker-run,$(args))
|
||||
,
|
||||
$(call ERROR,Unable to find docker image $(DOCKER_IMAGE))
|
||||
$(call ERROR,Unable to find docker image,$(DOCKER_IMAGE))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find any Dockerfile in dir: $(or $(1),$(APP_DIR)))
|
||||
$(call ERROR,Unable to find a,Dockerfile in dir,$(or $(1),$(APP_DIR)))
|
||||
)
|
||||
endef
|
||||
|
||||
# function app-up: Call docker-run (-d) for each Dockerfile in dir 1
|
||||
define app-up
|
||||
$(call INFO,app-up,$(1))
|
||||
$(if $(filter-out $(APP_DIR),$(1)),
|
||||
$(eval DOCKER_FILE := $(wildcard $(1)/docker/*/Dockerfile $(1)/*/Dockerfile $(1)/Dockerfile))
|
||||
)
|
||||
$(call INFO,app-up,$(1)$(comma))
|
||||
$(eval DOCKER_RUN_OPTIONS += -d)
|
||||
$(if $(DOCKER_FILE), \
|
||||
$(foreach dockerfile,$(DOCKER_FILE),
|
||||
$(call app-docker,$(dockerfile))
|
||||
$(if $(shell docker images -q $(DOCKER_IMAGE) 2>/dev/null),
|
||||
$(call docker-run,$(args))
|
||||
,
|
||||
$(call ERROR,Unable to find docker image $(DOCKER_IMAGE))
|
||||
)
|
||||
),
|
||||
$(call ERROR,Unable to find any Dockerfile in dir: $(or $(1),$(APP_DIR)))
|
||||
)
|
||||
$(call app-run,$(1))
|
||||
endef
|
||||
|
||||
# function app-update: Run 'cd dir 1 && git pull' or Call app-install
|
||||
|
||||
Reference in New Issue
Block a user