Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hsoerensen committed Jan 9, 2024
0 parents commit 1f98432
Show file tree
Hide file tree
Showing 7 changed files with 826 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
release:
types: [published]

jobs:
push_to_registries:
name: Push Docker image to registry
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
ghcr.io/${{ github.repository }}
- name: Build and push Docker images
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
build-args: |
BASE_ALGORAND_IMAGE=${{ github.event.release.tag_name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG BASE_ALGORAND_VERSION=3.20.1
FROM algorand/algod:$BASE_ALGORAND_VERSION-stable
LABEL "network.voi"="Voi Network"
LABEL version=$BASE_ALGORAND_VERSION

ENV NETWORK=voitest \
GENESIS_ADDRESS=https://testnet-api.voi.nodly.io \
TELEMETRY_NAME="${HOSTNAME}" \
## Mimics the behavior of Algorand's fast catchup variable, though they are less aggressive in catchup up when invoking `goal node catchup`
VOI_FAST_CATCHUP=1

COPY ./config.json /etc/algorand/config.json
COPY ./start.sh /node/run/start.sh
COPY ./voi-startup.sh /node/run/voi-catchup.sh

RUN apt-get update && apt-get dist-upgrade -y && apt install -y jq bc curl

CMD "/node/run/start.sh"
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Voi Network Participation Node Docker image

This repository contains a Dockerfile for building a Voi Network participation node Docker image.
The image contains no key material, and is intended to be used with a participation key injected at runtime.

## Building the image

The image can be built using the following command:

```bash
docker build .
```

To provide an Algorand version to use as base image, use the `BASE_ALGORAND_VERSION` build argument:
```bash
docker build --build-arg="BASE_ALGORAND_VERSION=3.20.1" .
```

The `BASE_ALGORAND_VERSION` argument is used to specify the version of the Algorand image to use as base image.
Defaults to `3.20.1`.

## Running the image

```bash
docker run <image_tag>
```

By default the image will listen on port 8080 for incoming connections. To run the image with the REST API exposed on
local port 8080 execute:
```bash
docker run -p 8080:8080 <image_tag>
```

## Container registry
Images will be published via GitHub Actions packaged releases and will be available at the following location:

```bash
docker pull ghcr.io/voinetwork/docker-participation-node:latest
```

Versioned images will be available by replacing `latest` with the desired version number.
```bash:
docker pull ghcr.io/voinetwork/docker-participation-node:3.20.1
```

## Creating a release
To create a release and publish the image to the container registry, create a new release in GitHub and tag it with the
version number of the Algorand image to use as base image. The GitHub Action will then build and publish the image to
registry.

## Notes

* Mount points inside the image are using the default Algorand mount points, which can be overridden for persistent claims.
* The image versioning is aligned with the official Algorand release versions.
* Catchup via the environment variable VOI_FAST_CATCHUP is set to true by default.
* This variable mimics the behavior from the Algorand image, but will result in faster catchup (as more aggressive).
7 changes: 7 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"EndpointAddress": "0.0.0.0:8080",
"DNSBootstrapID": "<network>.voi.network",
"EnableCatchupFromArchiveServers": true,
"BaseLoggerDebugLevel": 4,
"FallbackDNSResolverAddress": "1.1.1.1"
}
5 changes: 5 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e

/node/run/run.sh &
/node/run/voi-catchup.sh
30 changes: 30 additions & 0 deletions voi-startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

while ! goal node status
do
sleep 5
echo "Waiting for Algod"
done

## Catchup
if [ "$VOI_FAST_CATCHUP" = '1' ]; then
echo "fast catchup enabled"
myNodeRound=`goal node lastround`
blockchainRoundMath=$(curl -s https://testnet-api.voi.nodly.io/v2/status | jq -r '.["last-round"]' )" - 1000"
blockchainRound=$(echo $blockchainRoundMath | bc)

echo "catchup check: my round is $myNodeRound, blockchain round is $blockchainRound"
if [ "$myNodeRound" -lt "$blockchainRound" ]; then
echo "Executing catchup script because my current round is $myNodeRound"
catchup=$(curl -s https://testnet-api.voi.nodly.io/v2/status | jq -r '.["last-catchpoint"]')
sleep 10s
echo "going to run 'goal node catchup $catchup'"
goal node catchup $catchup || error_code=$?
if [ $error_code_int -ne 0 ]; then
echo "failed to start catchup";
exit 1;
fi
fi
fi

while true; do date; goal node status; sleep 600;done

0 comments on commit 1f98432

Please sign in to comment.