From 90aeaf6611512f76e730605a845e8feaa9f070b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 14 Sep 2018 10:41:26 +0200 Subject: [PATCH] Automatic project creation, Adjustible project folder naming scheme --- Makefile | 56 +++++++++++++++++++------- base.conf | 3 ++ default.docker.down/docker-compose.yml | 12 ------ 3 files changed, 44 insertions(+), 27 deletions(-) delete mode 100644 default.docker.down/docker-compose.yml diff --git a/Makefile b/Makefile index c1a5dd6..40e223b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,9 @@ endif FILE_DOCKERNET:=$(CONF_TARGETROOT)/up-$(CONF_DOCKERNET) # project directory handling -PROJ_WILDC:=$(wildcard *.docker) +PROJ_SUFFX:=$(call confvalue,SUFFIX_PROJECT) +DOWN_SUFFX:=$(call confvalue,SUFFIX_DOWN) +PROJ_WILDC:=$(wildcard *$(PROJ_SUFFX)) PROJ_NAMES:=$(basename $(PROJ_WILDC)) # different complexities of commands with root privileges @@ -58,7 +60,7 @@ net-down: down ######### # sync project config directory to variable folder .PHONY: %-copyconf -%-copyconf: %.docker +%-copyconf: %$(PROJ_SUFFX) @if [ -d "$/dev/null | less -R +G .PHONY: %-logf -%-logf: %.docker +%-logf: %$(PROJ_SUFFX) $(call sudocompose,logs -tf --tail=10 $(x)) ||: s?=bash .PHONY: %-sh -%-sh: %.docker +%-sh: %$(PROJ_SUFFX) $(call sudocompose,exec $(x) $(s)) ||: # enabling and disabling .PHONY: %-enable %-disable -%-enable: %.docker.down +%-enable: %$(PROJ_SUFFX)$(DOWN_SUFFX) mv "$<" "$(basename $<)" -%-disable: %.docker - mv "$<" "$<.down" +%-disable: %$(PROJ_SUFFX) + mv "$<" "$<$(DOWN_SUFFX)" # Combinations .PHONY: %-update -%-update: %.docker %-build %-pull +%-update: %$(PROJ_SUFFX) %-build %-pull $(MAKE) $(basename $<)-up # Arbitrary compose command .PHONY: %-cmd -%-cmd: %.docker +%-cmd: %$(PROJ_SUFFX) $(call sudocompose,$(x)) +######### +# project creation +.PHONY: %-new +%-new: + $(eval proj_dir:=$(patsubst %-new,%$(PROJ_SUFFX)$(DOWN_SUFFX),$@)) + mkdir $(proj_dir) + $(eval export COMPOSEFILE) + echo -e "$$COMPOSEFILE" > $(proj_dir)/docker-compose.yml + +# default compose file +define COMPOSEFILE +version: '2' + +networks: + default: + external: + name: $$DOCKERNET + +services: + something: + image: maintainer/repo:tag + restart: unless-stopped + [...] +endef diff --git a/base.conf b/base.conf index 434ea75..49c1b20 100644 --- a/base.conf +++ b/base.conf @@ -1,2 +1,5 @@ +export SUFFIX_PROJECT=.project +export SUFFIX_DOWN=.down + export DOCKERNET=kiwinet export TARGETROOT=/var/kiwi diff --git a/default.docker.down/docker-compose.yml b/default.docker.down/docker-compose.yml deleted file mode 100644 index 2d35141..0000000 --- a/default.docker.down/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '2' - -networks: - default: - external: - name: $DOCKERNET - -services: - something: - image: maintainer/repo:tag - restart: unless-stopped - [...] \ No newline at end of file