From a1ff437a27f5fb45fce0d95590669b86c0a07e44 Mon Sep 17 00:00:00 2001 From: "Ryan T. Moran" Date: Sun, 28 Nov 2021 22:09:27 -0500 Subject: [PATCH] Included working five-node exit node docker-compose configurations --- Makefile | 62 ++++++++++++----------- build/docker-entrypoint.sh | 56 ++++++++++----------- config/five-node-exit/host11.rc | 23 ++++++--- config/five-node-exit/host12.rc | 50 +++++++++++-------- config/five-node-exit/host13.rc | 53 ++++++++++++-------- config/five-node-exit/host14.rc | 46 +++++++++-------- config/sample.rc | 56 +++++++++++++++++++++ config/two-node/host11.rc | 3 ++ deploy/example1/docker-compose.yaml | 13 +++-- deploy/example2/docker-compose.yaml | 76 +++++++++++++++++++++++++++++ 10 files changed, 311 insertions(+), 127 deletions(-) create mode 100644 config/sample.rc create mode 100644 deploy/example2/docker-compose.yaml diff --git a/Makefile b/Makefile index 465dd28..49d107c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +# ION-DTN Docker Container +# Ryan T. Moran +# Development Makefile: This Makefile is provided to simplify regular Docker commands that a +# ION-DTN tester might likely encounter. +# # import deploy config dpl ?= deploy.env include $(dpl) @@ -5,8 +10,8 @@ export $(shell sed 's/=.*//' $(dpl)) .SILENT: -.PHONY: help build-% build-nc-% up-% down-% \ - publish-version-% publish-% tag-latest-% \ +.PHONY: help build build-nc up-% down-% \ + publish-version-% publish tag tag-latest-% \ tag-version-% repo-login # HELP @@ -20,27 +25,26 @@ help: ## For this help menu SHELL=/usr/bin/bash # DOCKER TASKS + build-all: @-for i in $(COMPOSE_EXAMPLES); do \ make build-$$i:latest; \ done # Build the container -build-%: ## Build and tag ion container from `Dockerfile`; build-{image_name:version} - $(eval image := $(firstword $(subst :, ,$*))) - $(eval version := $(lastword $(subst :, ,$*))) - @if [ "$(image)" = "$(version)" ]; then \ - echo -e "Error: version not provided.\\n"; \ - make -s help; exit 1; \ - fi - @echo "[ion] Building container $*" - docker build -t ${image}:${version} -f build/Dockerfile . - -build-nc-%: ## Build and tag ion container from `Dockerfile` without caching; ex: build-nc-{image_name:version} - $(eval image := $(firstword $(subst :, ,$*))) - $(eval version := $(lastword $(subst :, ,$*))) +# build-%: ## Build and tag ion container from `Dockerfile`; build-{image_name:version} +build: ## Build and tag ion container from `Dockerfile`; build-{image_name:version} + @echo "[ion] Building container local/ion-dtn" + docker build -t local/ion-dtn:latest -f build/Dockerfile . + +# build-nc-%: ## Build and tag ion container from `Dockerfile` without caching; ex: build-nc-{image_name:version} +build-nc: ## Build and tag ion container from `Dockerfile` without caching; ex: build-nc-{image_name:version} @echo "[ion] Building container --no-cache $*" - docker build --no-cache -t ${image}:${version} -f build/Dockerfile . + docker build --no-cache -t local/ion-dtn:latest -f build/Dockerfile . + +_up-sample1: ## Start docker compose example2 environment (docker-compose) + @echo "[ion] Starting docker-compose sample1 environment" + docker-compose --file deploy/sample1/docker-compose.yaml up _up-example1: ## Start docker compose example1 environment (docker-compose) @echo "[ion] Starting docker-compose example1 environment" @@ -54,6 +58,11 @@ up-%: ## Bring up docker compose environment `{example1, example2, ...}`; ex: up $(eval context := $*) @if [ "$(context)" = "example1" ]; then make -s _up-example1; fi @if [ "$(context)" = "example2" ]; then make -s _up-example2; fi + @if [ "$(context)" = "sample1" ]; then make -s _up-sample1; fi + +_down-sample1: ## Bring down docker compose example2 environment (docker-compose) + @echo "[ion] Bringing down docker-compose sample1" + docker-compose --file deploy/sample1/docker-compose.yaml down _down-example1: ## Bring down docker compose example1 environment (docker-compose) @echo "[ion] Bringing down docker-compose example1" @@ -73,18 +82,15 @@ down-%: ## Bring down docker compose environment `{example1, example2, ...}` # make publish-$$i:latest; \ # done -publish-%: ## Publish the `{container:version}` tagged container to ECR - $(eval image := $(firstword $(subst :, ,$*))) - $(eval version := $(lastword $(subst :, ,$*))) - @echo '[ion] Publish $* to $(DOCKER_REPO)' - @make -s repo-login tag-$* - docker push $(DOCKER_REPO)/${image}:${version} +# publish-%: ## Publish the `{container:version}` tagged container to ECR +publish: ## Publish the `{container:version}` tagged container to ECR + @echo '[ion] Publishing ion-dtn to repositiory' + @make -s repo-login tag + docker push $(DOCKER_USER)/ion-dtn:latest -tag-%: ## Generate container `{container:version}` ECR tag - $(eval image := $(firstword $(subst :, ,$*))) - $(eval version := $(lastword $(subst :, ,$*))) +tag: ## Generate container `{container:version}` ECR tag @echo '[ion] Create AWS ECR tag for container $*' - docker tag ${image}:${version} $(DOCKER_REPO)/${image}:${version} + docker tag local/ion-dtn:latest ${DOCKER_USER}/ion-dtn:latest prune-network: ## Clean all docker network resources @echo '[ion] Removing all docker network resources...' @@ -96,8 +102,8 @@ prune: ## Clean all docker resources - images, containers, volumes & networks # HELPERS # generate script to login to aws docker repo -CMD_REPOLOGIN := "aws ecr get-login-password --region ${AWS_CLI_REGION} | \ - docker login --username AWS --password-stdin $(DOCKER_REPO)" +CMD_REPOLOGIN := "echo ${DOCKER_ACCESS_TOKEN} | \ + docker login --username ${DOCKER_USER} --password-stdin" VERSION := "git --no-pager log -1 --oneline --format=\"%Cblue%h %Cgreen%D\"" diff --git a/build/docker-entrypoint.sh b/build/docker-entrypoint.sh index 115dc00..b088465 100755 --- a/build/docker-entrypoint.sh +++ b/build/docker-entrypoint.sh @@ -1,41 +1,41 @@ #!/bin/bash +# Docker entrypoint for ION-DTN container image +# Ryan T. Moran +# set -e +declare -r ion_version='4.10' +declare -r default_config_location='/usr/local/etc/ion/ion.rc' + # if first argument is single/double flag (-f | --option) if [ "${1#-}" != "$1" ]; then - echo "entry 1" + echo "entry 1" set -- ionstart "$@" -fi - # if first argument has 'rc' extension -if [ "${1%.rc}" != "$1" ]; then - echo "entry 2" - set -- ionstart -I "$@" -fi +elif [ "${1%.rc}" != "$1" ]; then + echo "entry 2" + set -- ionstart -I "$@" +elif [ "$1" = 'ionstart' -a "$(id -u)" = '0' ]; then + # find . \! -user ionserv -exec chown ionserv:ionserv '{}' + + set -- gosu ionserv "$0" "$@" -if [ ${#} == 0 -o "${1}" != "ionstart" ]; then - echo "entry 3" - ionstart -I "${ION_CONFIG_PATH:="/usr/local/etc/ion/ion.rc"}" - set -- "$@" +elif [ ${#} == 0 -o "${1}" != "ionstart" ]; then + echo "entry 3" + ionstart -I "${ION_CONFIG_PATH:=$default_config_location}" + set -- "$@" fi -# allow the container to be started with `--user` -# if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then -# find . \! -user redis -exec chown redis '{}' + -# exec gosu redis "$0" "$@" -# fi +"$@" -echo "\ -ION DTNv4.10 -$(bpversion) -Container intialized" +cat << EOF -echo "$@" -"$@" +ION Docker Container Started: + ION-DTN: v${ion_version} + Bundle Protocol: $(bpversion) + + to return +EOF -# ion tools do not run in foreground causing container -# to terminate on 'ionstart' return value -while true -do - sleep 1 -done +# necessary until ionstart entrypoint is rewritten +# to support foreground starts +sleep infinity \ No newline at end of file diff --git a/config/five-node-exit/host11.rc b/config/five-node-exit/host11.rc index f961bc2..940d8bb 100644 --- a/config/five-node-exit/host11.rc +++ b/config/five-node-exit/host11.rc @@ -1,3 +1,6 @@ +## ION-DTN configuration for node-11 (ipn:11.x) +## Ryan T. Moran + ## begin ionadmin 1 11 '' s @@ -5,12 +8,16 @@ s m horizon +0 a contact +0 +3600 11 11 10000000 1 -a contact +0 +3600 11 10 10000000 1 a contact +0 +3600 10 11 10000000 1 +a contact +0 +3600 11 10 10000000 1 +a contact +0 +3600 12 11 10000000 1 +a contact +0 +3600 11 12 10000000 1 -a range +0 +3600 11 11 1 +a range +0 +3600 10 10 1 a range +0 +3600 10 11 1 a range +0 +3600 11 10 1 +a range +0 +3600 12 11 1 +a range +0 +3600 11 12 1 m production 10000000 m consumption 10000000 @@ -23,10 +30,11 @@ m consumption 10000000 ## begin ltpadmin 1 32 -a span 11 32 32 1400 10000 1 'udplso ion-node-2:1113' 300 -a span 10 32 32 1400 10000 1 'udplso ion-node-1:1113' 300 +a span 10 32 32 1400 10000 1 'udplso ion-node-10:1113' 300 +a span 11 32 32 1400 10000 1 'udplso ion-node-11:1113' 300 +a span 12 32 32 1400 10000 1 'udplso ion-node-12:1113' 300 -s 'udplsi ion-node-2:1113' +s 'udplsi ion-node-11:1113' ## end ltpadmin ## begin bpadmin @@ -44,6 +52,7 @@ a induct ltp 11 ltpcli a outduct ltp 11 ltpclo a outduct ltp 10 ltpclo +a outduct ltp 12 ltpclo s ## end bpadmin @@ -51,5 +60,7 @@ s ## begin ipnadmin a plan 11 ltp/11 a plan 10 ltp/10 +a plan 12 ltp/12 -## end ipnadmin +a exit 14 14 ipn:12.0 +## end ipnadmin \ No newline at end of file diff --git a/config/five-node-exit/host12.rc b/config/five-node-exit/host12.rc index cd10e73..3da3f93 100644 --- a/config/five-node-exit/host12.rc +++ b/config/five-node-exit/host12.rc @@ -1,16 +1,23 @@ +## ION-DTN configuration for node-12 (ipn:12.x) +## Ryan T. Moran + ## begin ionadmin -1 10 '' +1 12 '' s m horizon +0 -a contact +0 +3600 10 10 10000000 1 -a contact +0 +3600 10 11 10000000 1 -a contact +0 +3600 11 10 10000000 1 +a contact +0 +3600 12 12 10000000 1 +a contact +0 +3600 12 11 10000000 1 +a contact +0 +3600 11 12 10000000 1 +a contact +0 +3600 12 13 10000000 1 +a contact +0 +3600 13 12 10000000 1 -a range +0 +3600 10 10 1 -a range +0 +3600 10 11 1 -a range +0 +3600 11 10 1 +a range +0 +3600 12 12 1 +a range +0 +3600 12 11 1 +a range +0 +3600 11 12 1 +a range +0 +3600 12 13 1 +a range +0 +3600 13 12 1 m production 10000000 m consumption 10000000 @@ -23,33 +30,38 @@ m consumption 10000000 ## begin ltpadmin 1 32 -a span 10 32 32 1400 10000 1 'udplso ion-node-1:1113' 300 -a span 11 32 32 1400 10000 1 'udplso ion-node-2:1113' 300 +a span 12 32 32 1400 10000 1 'udplso ion-node-12:1113' 300 +a span 11 32 32 1400 10000 1 'udplso ion-node-11:1113' 300 +a span 13 32 32 1400 10000 1 'udplso ion-node-13:1113' 300 -s 'udplsi ion-node-1:1113' +s 'udplsi ion-node-12:1113' ## end ltpadmin ## begin bpadmin 1 a scheme ipn 'ipnfw' 'ipnadminep' a scheme imc 'imcfw' 'imcadminep' -a endpoint ipn:10.0 q -a endpoint ipn:10.1 q -a endpoint ipn:10.2 q -a endpoint ipn:10.64 q -a endpoint ipn:10.65 q +a endpoint ipn:12.0 q +a endpoint ipn:12.1 q +a endpoint ipn:12.2 q +a endpoint ipn:12.64 q +a endpoint ipn:12.65 q a protocol ltp 1400 100 -a induct ltp 10 ltpcli +a induct ltp 12 ltpcli -a outduct ltp 10 ltpclo +a outduct ltp 12 ltpclo a outduct ltp 11 ltpclo +a outduct ltp 13 ltpclo s ## end bpadmin ## begin ipnadmin -a plan 10 ltp/10 +a plan 12 ltp/12 a plan 11 ltp/11 +a plan 13 ltp/13 -## end ipnadmin +a exit 14 14 ipn:13.0 +a exit 10 10 ipn:11.0 +## end ipnadmin \ No newline at end of file diff --git a/config/five-node-exit/host13.rc b/config/five-node-exit/host13.rc index f961bc2..23372d6 100644 --- a/config/five-node-exit/host13.rc +++ b/config/five-node-exit/host13.rc @@ -1,16 +1,23 @@ +## ION-DTN configuration for node-13 (ipn:13.x) +## Ryan T. Moran + ## begin ionadmin -1 11 '' +1 13 '' s m horizon +0 -a contact +0 +3600 11 11 10000000 1 -a contact +0 +3600 11 10 10000000 1 -a contact +0 +3600 10 11 10000000 1 +a contact +0 +3600 13 13 10000000 1 +a contact +0 +3600 13 12 10000000 1 +a contact +0 +3600 12 13 10000000 1 +a contact +0 +3600 13 14 10000000 1 +a contact +0 +3600 14 13 10000000 1 -a range +0 +3600 11 11 1 -a range +0 +3600 10 11 1 -a range +0 +3600 11 10 1 +a range +0 +3600 13 13 1 +a range +0 +3600 13 12 1 +a range +0 +3600 12 13 1 +a range +0 +3600 13 14 1 +a range +0 +3600 14 13 1 m production 10000000 m consumption 10000000 @@ -23,33 +30,37 @@ m consumption 10000000 ## begin ltpadmin 1 32 -a span 11 32 32 1400 10000 1 'udplso ion-node-2:1113' 300 -a span 10 32 32 1400 10000 1 'udplso ion-node-1:1113' 300 +a span 13 32 32 1400 10000 1 'udplso ion-node-13:1113' 300 +a span 12 32 32 1400 10000 1 'udplso ion-node-12:1113' 300 +a span 14 32 32 1400 10000 1 'udplso ion-node-14:1113' 300 -s 'udplsi ion-node-2:1113' +s 'udplsi ion-node-13:1113' ## end ltpadmin ## begin bpadmin 1 a scheme ipn 'ipnfw' 'ipnadminep' a scheme imc 'imcfw' 'imcadminep' -a endpoint ipn:11.0 q -a endpoint ipn:11.1 q -a endpoint ipn:11.2 q -a endpoint ipn:11.64 q -a endpoint ipn:11.65 q +a endpoint ipn:13.0 q +a endpoint ipn:13.1 q +a endpoint ipn:13.2 q +a endpoint ipn:13.64 q +a endpoint ipn:13.65 q a protocol ltp 1400 100 -a induct ltp 11 ltpcli +a induct ltp 13 ltpcli -a outduct ltp 11 ltpclo -a outduct ltp 10 ltpclo +a outduct ltp 13 ltpclo +a outduct ltp 12 ltpclo +a outduct ltp 14 ltpclo s ## end bpadmin ## begin ipnadmin -a plan 11 ltp/11 -a plan 10 ltp/10 +a plan 13 ltp/13 +a plan 12 ltp/12 +a plan 14 ltp/14 -## end ipnadmin +a exit 10 10 ipn:12.0 +## end ipnadmin \ No newline at end of file diff --git a/config/five-node-exit/host14.rc b/config/five-node-exit/host14.rc index f961bc2..65feeb8 100644 --- a/config/five-node-exit/host14.rc +++ b/config/five-node-exit/host14.rc @@ -1,16 +1,19 @@ +## ION-DTN configuration for node-14 (ipn:14.x) +## Ryan T. Moran + ## begin ionadmin -1 11 '' +1 14 '' s m horizon +0 -a contact +0 +3600 11 11 10000000 1 -a contact +0 +3600 11 10 10000000 1 -a contact +0 +3600 10 11 10000000 1 +a contact +0 +3600 14 14 10000000 1 +a contact +0 +3600 14 13 10000000 1 +a contact +0 +3600 13 14 10000000 1 -a range +0 +3600 11 11 1 -a range +0 +3600 10 11 1 -a range +0 +3600 11 10 1 +a range +0 +3600 14 14 1 +a range +0 +3600 14 13 1 +a range +0 +3600 13 14 1 m production 10000000 m consumption 10000000 @@ -23,33 +26,34 @@ m consumption 10000000 ## begin ltpadmin 1 32 -a span 11 32 32 1400 10000 1 'udplso ion-node-2:1113' 300 -a span 10 32 32 1400 10000 1 'udplso ion-node-1:1113' 300 +a span 14 32 32 1400 10000 1 'udplso ion-node-14:1113' 300 +a span 13 32 32 1400 10000 1 'udplso ion-node-13:1113' 300 -s 'udplsi ion-node-2:1113' +s 'udplsi ion-node-14:1113' ## end ltpadmin ## begin bpadmin 1 a scheme ipn 'ipnfw' 'ipnadminep' a scheme imc 'imcfw' 'imcadminep' -a endpoint ipn:11.0 q -a endpoint ipn:11.1 q -a endpoint ipn:11.2 q -a endpoint ipn:11.64 q -a endpoint ipn:11.65 q +a endpoint ipn:14.0 q +a endpoint ipn:14.1 q +a endpoint ipn:14.2 q +a endpoint ipn:14.64 q +a endpoint ipn:14.65 q a protocol ltp 1400 100 -a induct ltp 11 ltpcli +a induct ltp 14 ltpcli -a outduct ltp 11 ltpclo -a outduct ltp 10 ltpclo +a outduct ltp 14 ltpclo +a outduct ltp 13 ltpclo s ## end bpadmin ## begin ipnadmin -a plan 11 ltp/11 -a plan 10 ltp/10 +a plan 14 ltp/14 +a plan 13 ltp/13 -## end ipnadmin +a exit 10 10 ipn:13.0 +## end ipnadmin \ No newline at end of file diff --git a/config/sample.rc b/config/sample.rc new file mode 100644 index 0000000..57207d7 --- /dev/null +++ b/config/sample.rc @@ -0,0 +1,56 @@ +## begin ionadmin +1 91 '' +s + +m horizon +0 + +a contact +0 +3600 91 91 10000000 1 +a contact +0 +3600 91 9 10000000 1 +a contact +0 +3600 9 91 10000000 1 + +a range +0 +3600 91 91 1 +a range +0 +3600 91 9 1 +a range +0 +3600 9 91 1 + + +m production 10000000 +m consumption 10000000 +## end ionadmin + +## begin ionsecadmin +1 +## end ionsecadmin + +## begin ltpadmin +1 32 + +a span 91 32 32 1400 10000 1 'udplso 35.231.54.22:1113' 300 +a span 9 32 32 1400 10000 1 'udplso ipnsig.rtmoran.org:1113' 300 + +s 'udplsi 192.168.1.13:1113' +## end ltpadmin + +## begin bpadmin +1 +a scheme ipn 'ipnfw' 'ipnadminep' +a scheme imc 'imcfw' 'imcadminep' +a endpoint ipn:91.0 q +a endpoint ipn:91.1 q +a endpoint ipn:91.2 q +a endpoint ipn:91.64 q +a endpoint ipn:91.65 q + +a protocol ltp 1400 100 +a induct ltp 91 ltpcli + +a outduct ltp 9 ltpclo +a outduct ltp 91 ltpclo + +s +## end bpadmin + +## begin ipnadmin +a plan 9 ltp/9 +a plan 91 ltp/91 + +## end ipnadmin diff --git a/config/two-node/host11.rc b/config/two-node/host11.rc index f961bc2..5565457 100644 --- a/config/two-node/host11.rc +++ b/config/two-node/host11.rc @@ -1,3 +1,6 @@ +## ION-DTN configuration for node-11 (ipn:11.x) +## Ryan T. Moran + ## begin ionadmin 1 11 '' s diff --git a/deploy/example1/docker-compose.yaml b/deploy/example1/docker-compose.yaml index a404266..b5b32e4 100644 --- a/deploy/example1/docker-compose.yaml +++ b/deploy/example1/docker-compose.yaml @@ -1,7 +1,12 @@ +# Example Docker-Compose configuration for testing ION-DTN +# Two-node Ping: This example demonstrates a simple ping utility between ipn:10.1 +# and ipn:11.1. +# Ryan T. Moran +# version: "3.8" services: ion-node-1: - image: ion-node:latest + image: local/ion-dtn:latest ports: - "1113/udp" environment: @@ -10,12 +15,12 @@ services: - ../../config/two-node:/usr/local/etc/ion:ro command: [ - "docker-entrypoint.sh", "bpecho", "ipn:10.1", "-C" + "bpecho", "ipn:10.1", "-C" ] networks: - ion-net ion-node-2: - image: ion-node:latest + image: local/ion-dtn:latest ports: - "1113/udp" environment: @@ -24,7 +29,7 @@ services: - ../../config/two-node:/usr/local/etc/ion:ro command: [ - "docker-entrypoint.sh", "bping", "-C", "ipn:11.1", "ipn:10.1" + "bping", "-C", "ipn:11.1", "ipn:10.1" ] networks: - ion-net diff --git a/deploy/example2/docker-compose.yaml b/deploy/example2/docker-compose.yaml new file mode 100644 index 0000000..383f19a --- /dev/null +++ b/deploy/example2/docker-compose.yaml @@ -0,0 +1,76 @@ +# Example Docker-Compose configuration for testing ION-DTN +# Five-node Exit Ping: This example demonstrates a simple ping utility between ipn:10.1 +# and ipn:14.1 by way of nodes ipn:10 => ipn:11 => ipn:12 => ipn:14 => ipn:15 +# through use of predefined exit-node configurations. +# Ryan T. Moran +# +version: "3.8" +services: + ion-node-10: + image: local/ion-dtn:latest + ports: + - "1113/udp" + environment: + ION_CONFIG_PATH: "/usr/local/etc/ion/host10.rc" + volumes: + - ../../config/five-node-exit:/usr/local/etc/ion:ro + command: + [ + # "bping", "-C", "ipn:10.2", "ipn:14.2" + "bpecho", "ipn:10.1", "-C" + ] + networks: + - ion-net + ion-node-11: + image: local/ion-dtn:latest + ports: + - "1113/udp" + environment: + ION_CONFIG_PATH: "/usr/local/etc/ion/host11.rc" + volumes: + - ../../config/five-node-exit:/usr/local/etc/ion:ro + command: + [ "tail", "-f", "ion.log"] + networks: + - ion-net + ion-node-12: + image: local/ion-dtn:latest + ports: + - "1113/udp" + environment: + ION_CONFIG_PATH: "/usr/local/etc/ion/host12.rc" + volumes: + - ../../config/five-node-exit:/usr/local/etc/ion:ro + command: + [ "tail", "-f", "ion.log"] + networks: + - ion-net + ion-node-13: + image: local/ion-dtn:latest + ports: + - "1113/udp" + environment: + ION_CONFIG_PATH: "/usr/local/etc/ion/host13.rc" + volumes: + - ../../config/five-node-exit:/usr/local/etc/ion:ro + command: + [ "tail", "-f", "ion.log"] + networks: + - ion-net + ion-node-14: + image: local/ion-dtn:latest + ports: + - "1113/udp" + environment: + ION_CONFIG_PATH: "/usr/local/etc/ion/host14.rc" + volumes: + - ../../config/five-node-exit:/usr/local/etc/ion:ro + command: + [ + # "bpecho", "ipn:14.2", "-C" + "bping", "-C", "ipn:14.1", "ipn:10.1" + ] + networks: + - ion-net +networks: + ion-net: