Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ on:
push:
branches:
- master
- rel/*
- feature/*
tags:
- "*"

jobs:
build:
build-and-push:
name: Build and Push to DockerHub
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand All @@ -25,9 +23,7 @@ jobs:
docker.io/${{ github.repository_owner }}/algod
tags: |
type=sha,format=long,prefix=
type=ref,event=tag
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'rel/stable') }}

- name: Login to Docker Hub
uses: docker/login-action@v2
Expand Down Expand Up @@ -55,3 +51,19 @@ jobs:
SHA=${{ github.sha }}
URL=${{ github.server_url }}/${{ github.repository }}.git
BRANCH=${{ github.ref_name }}

update-repo-description:
name: Update DockerHub Repository Description
runs-on: ubuntu-latest
if: github.ref == format('refs/heads/{0}', 'master')
Comment thread
algolucky marked this conversation as resolved.
Outdated
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Update DockerHub Repository Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ github.repository_owner }}/algod
readme-filepath: ./docker/README.md
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN /dist/files/build/install.sh \

FROM debian:bullseye-slim as final

ENV PATH="/node/bin:${PATH}" ALGOD_PORT="8080" ALGORAND_DATA="/algod/data"
ENV PATH="/node/bin:${PATH}" ALGOD_PORT="8080" KMD_PORT="7833" ALGORAND_DATA="/algod/data"

# curl is needed to lookup the fast catchup url
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && \
Expand All @@ -58,8 +58,8 @@ USER algorand
COPY --chown=algorand:algorand --from=builder "/dist/bin/" "/node/bin/"
COPY --chown=algorand:algorand --from=builder "/dist/files/run/" "/node/run/"

# Expose Algod REST API, Algod Gossip, and Prometheus Metrics ports
EXPOSE $ALGOD_PORT 4160 9100
# Expose Algod REST API, KMD REST API, Algod Gossip, and Prometheus Metrics ports
EXPOSE $ALGOD_PORT $KMD_PORT 4160 9100

WORKDIR /algod

Expand Down
25 changes: 13 additions & 12 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ By default the following config.json overrides are applied:

| Setting | Value |
| ------- | ----- |
| GossipFanout | 1 |
| EndpointAddress | 0.0.0.0:8080 |
| IncomingConnectionsLimit | 0 |
| Archival | false |
| IsIndexerActive | false |
| EnableDeveloperAPI | true |

### Environment Variables

Expand All @@ -28,12 +23,14 @@ The following environment variables can be supplied. Except when noted, it is po
| Variable | Description |
| -------- | ----------- |
| NETWORK | Leave blank for a private network, otherwise specify one of mainnet, betanet, testnet, or devnet. Only used during a data directory initialization. |
| FAST_CATCHUP | If set on a public network, attempt to start fast-catchup during initial config. |
| FAST_CATCHUP | If set to 1 on a public network, attempt to start fast-catchup during initial config. |
| TELEMETRY_NAME| If set on a public network, telemetry is reported with this name. |
| DEV_MODE | If set on a private network, enable dev mode. Only used during data directory initialization. |
| DEV_MODE | If set to 1 on a private network, enable dev mode. Only used during data directory initialization. |
| NUM_ROUNDS | If set on a private network, override default of 30000 participation keys. |
| TOKEN | If set, overrides the REST API token. |
| ADMIN_TOKEN | If set, overrides the REST API admin token. |
| KMD_TOKEN | If set along with `START_KMD`, override the KMD REST API token. |
| START_KMD | When set to 1, start kmd service with no timeout. THIS SHOULD NOT BE USED IN PRODUCTION. |

### Special Files

Expand All @@ -55,22 +52,26 @@ The following command launches a container configured with one of the public net
```bash
docker run --rm -it \
-p 4190:8080 \
-p 4191:7833 \
-e NETWORK=mainnet \
-e FAST_CATCHUP=1 \
-e TELEMETRY_NAME=name \
-e TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
-e START_KMD=1 \
-v ${PWD}/data:/algod/data/ \
--name mainnet-container \
algorand/algod:latest
```

Explanation of parts:

* `-p 4190:8080` maps the internal algod REST API to local port 4190
* `-e NETWORK=` can be set to any of the supported public networks.
* `-e FAST_CATCHUP=` causes fast catchup to start shortly after launching the network.
* `-e TELEMETRY_NAME=` enables telemetry reporting to Algorand for network health analysis. The value of this variable takes precedence over the `name` attribute set in `/etc/algorand/logging.config`.
* `-e TOKEN=` sets the REST API token to use.
* `-p 4190:8080` maps the internal algod REST API to local port 4190.
* `-p 4191:7833` maps the internal kmd REST API to local port 4191.
* `-e NETWORK=mainnet` can be set to any of the supported public networks.
* `-e TELEMETRY_NAME=name` enables telemetry reporting to Algorand for network health analysis. The value of this variable takes precedence over the `name` attribute set in `/etc/algorand/logging.config`.
* `-e FAST_CATCHUP=1` causes fast catchup to start shortly after launching the network.
* `-e START_KMD=1` signals to entrypoint to start the kmd REST API (THIS SHOULD NOT BE USED IN PRODUCTION).
* `-e TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` sets the REST API token to use.
* `-v ${PWD}/data:/algod/data/` mounts a local volume to the data directory, which can be used to restart and upgrade the deployment.

## Mounting the Data Directory
Expand Down
121 changes: 74 additions & 47 deletions docker/files/run/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

set -ex
set -e

if [ "$DEBUG" = "1" ]; then
set -x
fi

# Script to configure or resume a network. Based on environment settings the
# node will be setup with a private network or connect to a public network.
Expand All @@ -9,8 +13,35 @@ set -ex
# Helper functions #
####################

function apply_configuration() {
function catchup() {
local FAST_CATCHUP_URL="https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/CHANNEL/latest.catchpoint"
local CATCHPOINT=$(curl -s ${FAST_CATCHUP_URL/CHANNEL/$NETWORK})
if [[ "$(echo $CATCHPOINT | wc -l | tr -d ' ')" != "1" ]]; then
echo "Problem starting fast catchup."
exit 1
fi

sleep 5
goal node catchup "$CATCHPOINT"
}

function start_public_network() {
cd "$ALGORAND_DATA"

configure_data_dir
start_kmd &

if [ "$FAST_CATCHUP" = "1" ]; then
catchup &
fi

# redirect output to stdout
algod -o
}

function configure_data_dir() {
cd "$ALGORAND_DATA"
algocfg -d . set -p EndpointAddress -v "0.0.0.0:${ALGOD_PORT}"

# check for config file overrides.
if [ -f "/etc/algorand/config.json" ]; then
Expand All @@ -26,7 +57,7 @@ function apply_configuration() {
cp /etc/algorand/logging.config logging.config
fi

# check for environment variable overrides.
# check for token overrides
if [ "$TOKEN" != "" ]; then
echo "$TOKEN" >algod.token
fi
Expand All @@ -41,40 +72,30 @@ function apply_configuration() {
else
diagcfg telemetry disable
fi
}

function catchup() {
local FAST_CATCHUP_URL="https://algorand-catchpoints.s3.us-east-2.amazonaws.com/channel/CHANNEL/latest.catchpoint"
local CATCHPOINT=$(curl -s ${FAST_CATCHUP_URL/CHANNEL/$NETWORK})
if [[ "$(echo $CATCHPOINT | wc -l | tr -d ' ')" != "1" ]]; then
echo "Problem starting fast catchup."
exit 1
# start kmd
if [ "$START_KMD" = "1" ]; then
local KMD_DIR="kmd-v0.5"
# on intial bootstrap, this directory won't exist.
mkdir -p "$KMD_DIR"
Comment thread
algolucky marked this conversation as resolved.
chmod 0700 "$KMD_DIR"
cd "$KMD_DIR"
if [ -f "/etc/algorand/kmd_config.json" ]; then
cp /etc/algorand/kmd_config.json kmd_config.json
else
echo "{ \"address\":\"0.0.0.0:${KMD_PORT}\", \"allowed_origins\":[\"*\"] }" >kmd_config.json
fi

if [ "$KMD_TOKEN" != "" ]; then
echo "$KMD_TOKEN" >kmd.token
fi
fi

sleep 5
goal node catchup "$CATCHPOINT"
}

function start_public_network() {
cd "$ALGORAND_DATA"

apply_configuration

if [[ $FAST_CATCHUP ]]; then
catchup &
function start_kmd() {
if [ "$START_KMD" = "1" ]; then
goal kmd start -d "$ALGORAND_DATA"
fi
# redirect output to stdout
algod -o
}

function configure_data_dir() {
cd "$ALGORAND_DATA"
algocfg -d . set -p GossipFanout -v 1
algocfg -d . set -p EndpointAddress -v "0.0.0.0:${ALGOD_PORT}"
algocfg -d . set -p IncomingConnectionsLimit -v 0
algocfg -d . set -p Archival -v false
algocfg -d . set -p IsIndexerActive -v false
algocfg -d . set -p EnableDeveloperAPI -v true
}

function start_new_public_network() {
Expand All @@ -95,20 +116,24 @@ function start_new_public_network() {

local ID
case $NETWORK in
mainnet) ID="<network>.algorand.network";;
testnet) ID="<network>.algorand.network";;
betanet) ID="<network>.algodev.network";;
alphanet) ID="<network>.algodev.network";;
devnet) ID="<network>.algodev.network";;
*) echo "Unknown network"; exit 1;;
mainnet) ID="<network>.algorand.network" ;;
testnet) ID="<network>.algorand.network" ;;
betanet) ID="<network>.algodev.network" ;;
alphanet) ID="<network>.algodev.network" ;;
devnet) ID="<network>.algodev.network" ;;
*)
echo "Unknown network"
exit 1
;;
esac
set -p DNSBootstrapID -v "$ID"

start_public_network
}

function start_private_network() {
apply_configuration
configure_data_dir
start_kmd

# TODO: Is there a way to properly exec a private network?
goal network start -r "${ALGORAND_DATA}/.."
Expand All @@ -117,7 +142,7 @@ function start_private_network() {

function start_new_private_network() {
local TEMPLATE="template.json"
if [ "$DEV_MODE" ]; then
if [ "$DEV_MODE" = "1" ]; then
TEMPLATE="devmode_template.json"
fi
sed -i "s/NUM_ROUNDS/${NUM_ROUNDS:-30000}/" "/node/run/$TEMPLATE"
Expand All @@ -131,13 +156,15 @@ function start_new_private_network() {
##############

echo "Starting Algod Docker Container"
echo " ALGORAND_DATA: $ALGORAND_DATA"
echo " NETWORK: $NETWORK"
echo " ALGOD_PORT: $ALGOD_PORT"
echo " FAST_CATCHUP: $FAST_CATCHUP"
echo " DEV_MODE: $DEV_MODE"
echo " TOKEN: $TOKEN"
echo " TELEMETRY_NAME $TELEMETRY_NAME"
echo " ALGORAND_DATA: $ALGORAND_DATA"
echo " NETWORK: $NETWORK"
echo " ALGOD_PORT: $ALGOD_PORT"
echo " FAST_CATCHUP: $FAST_CATCHUP"
echo " DEV_MODE: $DEV_MODE"
echo " TOKEN: ${TOKEN:-"Not Set"}"
echo " KMD_TOKEN: ${KMD_TOKEN:-"Not Set"}"
echo " TELEMETRY_NAME: $TELEMETRY_NAME"
echo " START_KMD: ${START_KMD:-"Not Set"}"

# If data directory is initialized, start existing environment.
if [ -f "$ALGORAND_DATA/../network.json" ]; then
Expand Down