mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-21 20:33:00 +00:00
Automatic project creation, Adjustible project folder naming scheme
This commit is contained in:
parent
33ec32add0
commit
90aeaf6611
3 changed files with 44 additions and 27 deletions
56
Makefile
56
Makefile
|
@ -21,7 +21,9 @@ endif
|
||||||
FILE_DOCKERNET:=$(CONF_TARGETROOT)/up-$(CONF_DOCKERNET)
|
FILE_DOCKERNET:=$(CONF_TARGETROOT)/up-$(CONF_DOCKERNET)
|
||||||
|
|
||||||
# project directory handling
|
# 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))
|
PROJ_NAMES:=$(basename $(PROJ_WILDC))
|
||||||
|
|
||||||
# different complexities of commands with root privileges
|
# different complexities of commands with root privileges
|
||||||
|
@ -58,7 +60,7 @@ net-down: down
|
||||||
#########
|
#########
|
||||||
# sync project config directory to variable folder
|
# sync project config directory to variable folder
|
||||||
.PHONY: %-copyconf
|
.PHONY: %-copyconf
|
||||||
%-copyconf: %.docker
|
%-copyconf: %$(PROJ_SUFFX)
|
||||||
@if [ -d "$</conf" ]; then \
|
@if [ -d "$</conf" ]; then \
|
||||||
sudo rsync -r "$</conf" "$(CONF_TARGETROOT)"; \
|
sudo rsync -r "$</conf" "$(CONF_TARGETROOT)"; \
|
||||||
echo "Synced '$</conf' to '$(CONF_TARGETROOT)'"; \
|
echo "Synced '$</conf' to '$(CONF_TARGETROOT)'"; \
|
||||||
|
@ -78,54 +80,78 @@ update: $(patsubst %,%-update,$(PROJ_NAMES))
|
||||||
#########
|
#########
|
||||||
# manage single project
|
# manage single project
|
||||||
.PHONY: %-up
|
.PHONY: %-up
|
||||||
%-up: %.docker %-copyconf
|
%-up: %$(PROJ_SUFFX) %-copyconf
|
||||||
$(call sudocompose,up -d $(x))
|
$(call sudocompose,up -d $(x))
|
||||||
|
|
||||||
.PHONY: %-down
|
.PHONY: %-down
|
||||||
ifeq ($(x),)
|
ifeq ($(x),)
|
||||||
%-down: %.docker
|
%-down: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,down)
|
$(call sudocompose,down)
|
||||||
else
|
else
|
||||||
%-down: %.docker
|
%-down: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,stop $(x))
|
$(call sudocompose,stop $(x))
|
||||||
$(call sudocompose,rm -f $(x))
|
$(call sudocompose,rm -f $(x))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: %-pull
|
.PHONY: %-pull
|
||||||
%-pull: %.docker
|
%-pull: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,pull $(x))
|
$(call sudocompose,pull $(x))
|
||||||
|
|
||||||
.PHONY: %-build
|
.PHONY: %-build
|
||||||
%-build: %.docker
|
%-build: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,build --pull $(x))
|
$(call sudocompose,build --pull $(x))
|
||||||
|
|
||||||
.PHONY: %-logs
|
.PHONY: %-logs
|
||||||
%-logs: %.docker
|
%-logs: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,logs -t $(x)) 2>/dev/null | less -R +G
|
$(call sudocompose,logs -t $(x)) 2>/dev/null | less -R +G
|
||||||
|
|
||||||
.PHONY: %-logf
|
.PHONY: %-logf
|
||||||
%-logf: %.docker
|
%-logf: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,logs -tf --tail=10 $(x)) ||:
|
$(call sudocompose,logs -tf --tail=10 $(x)) ||:
|
||||||
|
|
||||||
s?=bash
|
s?=bash
|
||||||
.PHONY: %-sh
|
.PHONY: %-sh
|
||||||
%-sh: %.docker
|
%-sh: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,exec $(x) $(s)) ||:
|
$(call sudocompose,exec $(x) $(s)) ||:
|
||||||
|
|
||||||
# enabling and disabling
|
# enabling and disabling
|
||||||
.PHONY: %-enable %-disable
|
.PHONY: %-enable %-disable
|
||||||
%-enable: %.docker.down
|
%-enable: %$(PROJ_SUFFX)$(DOWN_SUFFX)
|
||||||
mv "$<" "$(basename $<)"
|
mv "$<" "$(basename $<)"
|
||||||
%-disable: %.docker
|
%-disable: %$(PROJ_SUFFX)
|
||||||
mv "$<" "$<.down"
|
mv "$<" "$<$(DOWN_SUFFX)"
|
||||||
|
|
||||||
# Combinations
|
# Combinations
|
||||||
.PHONY: %-update
|
.PHONY: %-update
|
||||||
%-update: %.docker %-build %-pull
|
%-update: %$(PROJ_SUFFX) %-build %-pull
|
||||||
$(MAKE) $(basename $<)-up
|
$(MAKE) $(basename $<)-up
|
||||||
|
|
||||||
# Arbitrary compose command
|
# Arbitrary compose command
|
||||||
.PHONY: %-cmd
|
.PHONY: %-cmd
|
||||||
%-cmd: %.docker
|
%-cmd: %$(PROJ_SUFFX)
|
||||||
$(call sudocompose,$(x))
|
$(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
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
|
export SUFFIX_PROJECT=.project
|
||||||
|
export SUFFIX_DOWN=.down
|
||||||
|
|
||||||
export DOCKERNET=kiwinet
|
export DOCKERNET=kiwinet
|
||||||
export TARGETROOT=/var/kiwi
|
export TARGETROOT=/var/kiwi
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
version: '2'
|
|
||||||
|
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
external:
|
|
||||||
name: $DOCKERNET
|
|
||||||
|
|
||||||
services:
|
|
||||||
something:
|
|
||||||
image: maintainer/repo:tag
|
|
||||||
restart: unless-stopped
|
|
||||||
[...]
|
|
Loading…
Reference in a new issue