Skip to content

Commit

Permalink
Updated Makefile, added 'example2' docker-componse and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
rtmor committed Dec 6, 2021
1 parent a1ff437 commit a8223ea
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 18 deletions.
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ build: ## Build and tag ion container from `Dockerfile`; build-{image_name:versi

# 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 $*"
@echo "[ion-container] Building container --no-cache $*"
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"
@echo "[ion-container] 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"
@echo "[ion-container] Starting docker-compose example1 environment"
docker-compose --file deploy/example1/docker-compose.yaml up

_up-example2: ## Start docker compose example2 environment (docker-compose)
@echo "[ion] Starting docker-compose example2 environment"
@echo "[ion-container] Starting docker-compose example2 environment"
docker-compose --file deploy/example2/docker-compose.yaml up

up-%: ## Bring up docker compose environment `{example1, example2, ...}`; ex: up-example1
Expand All @@ -61,15 +61,15 @@ up-%: ## Bring up docker compose environment `{example1, example2, ...}`; ex: up
@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"
@echo "[ion-container] 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"
@echo "[ion-container] Bringing down docker-compose example1"
docker-compose --file deploy/example1/docker-compose.yaml down

_down-example2: ## Bring down docker compose example2 environment (docker-compose)
@echo "[ion] Bringing down docker-compose example2"
@echo "[ion-container] Bringing down docker-compose example2"
docker-compose --file deploy/example1/docker-compose.yaml down

down-%: ## Bring down docker compose environment `{example1, example2, ...}`
Expand All @@ -84,30 +84,30 @@ down-%: ## Bring down docker compose environment `{example1, example2, ...}`

# 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'
@echo '[ion-container] Publishing ion-container to repositiory'
@make -s repo-login tag
docker push $(DOCKER_USER)/ion-dtn:latest

tag: ## Generate container `{container:version}` ECR tag
@echo '[ion] Create AWS ECR tag for container $*'
@echo '[ion-container] Create DockerHub tag for container $*'
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...'
@echo '[ion-container] Removing all docker network resources...'
docker system network prune

prune: ## Clean all docker resources - images, containers, volumes & networks
@echo '[ion] Removing all docker resources...'
@echo '[ion-container] Removing all docker resources...'
docker system prune -a

# HELPERS
# generate script to login to aws docker repo
# script to login to dockerhub/aws/other 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\""

# login to AWS-ECR
# login to DockerHub
repo-login: ## Auto login to AWS-ECR unsing aws-cli
@eval $(CMD_REPOLOGIN)

Expand Down
145 changes: 145 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,148 @@
# ION-DTN Docker Container

The ION-DTN container is a pre-built ION image solution designed to support rapid ION node deployment and extend testing capabilities. In addition, through the extension of this container image with Docker Compose, multi-node testing environments are available in a matter of seconds.

## Table of Contents

1. [Installation](#installation)
- [Requirements](#requirements)
- [DockerHub](#dockerhub)
- [From Source](#build-source)
2. [Usage](#usage)
- [Configuration](#configuration)
- [Examples](#examples)
3. [Multi-Node Environments](#multi-node-with-docker-compose)
- [Configuration](#configuration)
- [Networking](#networking)

## Quick Start

This repository includes a Makefile to simplify the deployment of the following multi-node demonstrations:

#### 2-Node ION Ping

```bash
make up-example1
```

#### 5-Node ION Exit Node

```bash
make up-example2
```

## Installation

#### Requirements

- Docker _(latest recommended)_
- Docker Compose _(for multi-node operation)_

### DockerHub

Pull image directly from DockerHub.

`docker pull rtmoran/ion-dtn`

### Build Source

Clone repository and build from Dockerfile.

```
docker clone [email protected]:rtmor/ion-container.git
cd ion-container
docker build -t local/ion-dtn:latest -f build/Dockerfile .
```

## Usage

### Configuration

By default, ION-DTN container will look to `/usr/local/etc/ion/ion.rc` to load the node's configuration file unless other wise defined through the use of the `ION_CONFIG_PATH` environment variable.

Local ION configuration files may be passed to a ION container on run through the use of a Docker mount point. This can be achieved by specifiying the `-v | [--volume]` Docker flag on run.

### Examples

**Start Node:** \
`docker run -v ${LOCAL_CONFIG_DIR}:/usr/local/etc/ion -it --rm local/ion-dtn:latest /usr/local/etc/ion/${CONFIG_NAME}.rc`

**Start Node & Run Command:** \
`docker run -v ${LOCAL_CONFIG_DIR}:/usr/local/etc/ion -it --rm local/ion-dtn:latest bping ipn:10.1 ipn:11.1 -C`

## Multi-Node with Docker Compose

Multi-node testing environments can be achieved through the use of Docker-Compose configuration files. Included within this repository are several such examples residing within the `deploy` directory.

### Configuration

Basic requirements for a functional ION DTN container service includes the definition of a local mount point, from which an ION configuration file may be loaded with the use of the `ION_CONFIG_PATH` environment variable.

For instance, the following is a simple Docker-Compose configuration for two nodes taken from `deploy/example1`:

```
services:
ion-node-1:
image: local/ion-dtn:latest
ports:
- "1113/udp"
environment:
ION_CONFIG_PATH: "/usr/local/etc/ion/host10.rc"
volumes:
- ../../config/two-node:/usr/local/etc/ion:ro
command:
[
"bpecho", "ipn:10.1", "-C"
]
networks:
- ion-net
ion-node-2:
image: local/ion-dtn:latest
ports:
- "1113/udp"
environment:
ION_CONFIG_PATH: "/usr/local/etc/ion/host11.rc"
volumes:
- ../../config/two-node:/usr/local/etc/ion:ro
command:
[
"bping", "-C", "ipn:11.1", "ipn:10.1"
]
networks:
- ion-net
networks:
ion-net:
```

### Networking

A Docker-Compose networking interface can be defined for node services through the use of the `networks` configuration object.

Multi-node resolving is accomplished through the addressing of foreign nodes by their hostname within the local node's ION configuration file contact plans. A node's hostname is, by default, assigned to match the Docker-Compose configuration service key-value under which it resides.

#### docker-compose.yaml

```docker-compose
...
services:
ion-node-1:
image: local/ion-dtn:latest
...
```

#### node-2.rc

```
...
## 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
s 'udplsi ion-node-2:1113'
## end ltpadmin
...
```

More information coming...
6 changes: 4 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#
FROM debian:bullseye-slim AS builder

LABEL "org.rtmoran.version"="0.1"
LABEL "org.rtmoran.maintainer"="Ryan T. Moran <[email protected]>"
LABEL "org.rtmoran.description"="https://github.com/rtmor/ion-container"

ENV ION_SRC="ipnsig-pwg-main" \
ION_VERSION="ion-4.1.0"

Expand Down Expand Up @@ -46,5 +50,3 @@ EXPOSE 1113/udp
COPY build/docker-entrypoint.sh /usr/bin

ENTRYPOINT [ "docker-entrypoint.sh" ]

# CMD [ "/bin/bash", "-c" ]
4 changes: 1 addition & 3 deletions deploy/example2/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 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
# Ryan T. Moran, 2021
#
version: "3.8"
services:
Expand All @@ -16,7 +16,6 @@ services:
- ../../config/five-node-exit:/usr/local/etc/ion:ro
command:
[
# "bping", "-C", "ipn:10.2", "ipn:14.2"
"bpecho", "ipn:10.1", "-C"
]
networks:
Expand Down Expand Up @@ -67,7 +66,6 @@ services:
- ../../config/five-node-exit:/usr/local/etc/ion:ro
command:
[
# "bpecho", "ipn:14.2", "-C"
"bping", "-C", "ipn:14.1", "ipn:10.1"
]
networks:
Expand Down

0 comments on commit a8223ea

Please sign in to comment.