Skip to content

Commit

Permalink
Included working five-node exit node docker-compose configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
rtmor committed Nov 29, 2021
1 parent 9e702a9 commit a1ff437
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 127 deletions.
62 changes: 34 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# 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)
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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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...'
Expand All @@ -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\""

Expand Down
56 changes: 28 additions & 28 deletions build/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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)
<Ctrl-C> 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
23 changes: 17 additions & 6 deletions config/five-node-exit/host11.rc
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
## ION-DTN configuration for node-11 (ipn:11.x)
## Ryan T. Moran

## begin ionadmin
1 11 ''
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
Expand All @@ -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
Expand All @@ -44,12 +52,15 @@ a induct ltp 11 ltpcli

a outduct ltp 11 ltpclo
a outduct ltp 10 ltpclo
a outduct ltp 12 ltpclo

s
## end bpadmin

## 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
50 changes: 31 additions & 19 deletions config/five-node-exit/host12.rc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Loading

0 comments on commit a1ff437

Please sign in to comment.