1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-21 20:33:00 +00:00

internal networking

This commit is contained in:
Jörn-Michael Miehe 2018-12-06 14:43:26 +01:00
parent 95c5bcba1b
commit 746f28d65e
2 changed files with 20 additions and 6 deletions

View file

@ -13,6 +13,11 @@ ifeq ($(CONF_DOCKERNET),)
$(error DOCKERNET not set in $(CONF_WILDC))
endif
CONF_DOCKERCIDR:=$(call confvalue,DOCKERCIDR)
ifeq ($(CONF_DOCKERNET),)
$(error DOCKERCIDR not set in $(CONF_WILDC))
endif
# persistent data directory
CONF_TARGETROOT:=$(call confvalue,TARGETROOT)
ifeq ($(CONF_TARGETROOT),)
@ -62,18 +67,18 @@ all: purge-conf up
#########
# manage the docker network (container name local DNS)
$(FILE_DOCKERNET):
sudo docker network create "$(CONF_DOCKERNET)" ||:
sudo docker network create --driver bridge --internal --subnet "$(CONF_DOCKERCIDR)" "$(CONF_DOCKERNET)" ||:
sudo mkdir -p "$(CONF_TARGETROOT)"
sudo chmod 700 "$(CONF_TARGETROOT)"
sudo docker network inspect -f '{{(index .IPAM.Config 0).Subnet}}' "$(CONF_DOCKERNET)" | sudo tee "$@"
sudo echo "$(CONF_DOCKERCIDR)" | sudo tee "$@"
.PHONY: net-up
net-up: $(FILE_DOCKERNET)
.PHONY: net-down
net-down: down
sudo docker network rm $(CONF_DOCKERNET)
sudo rm $(FILE_DOCKERNET)
sudo docker network rm "$(CONF_DOCKERNET)"
sudo rm "$(FILE_DOCKERNET)"
#########
# sync project config directory to variable folder
@ -160,10 +165,14 @@ s?=bash
# default compose file
define COMPOSEFILE
version: "3"
version: "2"
networks:
default:
# reachable from outside
default:
driver: bridge
# interconnects projects
gassi:
external:
name: $$DOCKERNET
@ -171,5 +180,8 @@ services:
something:
image: maintainer/repo:tag
restart: unless-stopped
networks:
- default
- gassi
[...]
endef

View file

@ -2,4 +2,6 @@ export SUFFIX_PROJECT=.project
export SUFFIX_DOWN=.down
export DOCKERNET=kiwinet
export DOCKERCIDR=10.13.37.0/24
export TARGETROOT=/var/kiwi