Docker altnets (#708)

* Updated to check the boost SHA256 when downloading

* Fixed invalid shell option

* Allow the user to request a minimal build of Boost

* Ensure boost build script exits on error

* Removed apparently unused "mkdir"

* Updated Docker build for node to support altnets

* Allow user-supplied arguments to "docker build"

* Updated Docker auto deploy to build a live and beta image for each tag

* Print the correct image name when building the docker image

* Corrected typo for the test network
This commit is contained in:
Roy Keene 2018-03-08 12:03:26 -06:00 committed by clemahieu
commit 34b07f4ea2
8 changed files with 233 additions and 31 deletions

View file

@ -1,8 +1,17 @@
#!/bin/bash
set -eu
if [ "$#" -lt 2 ]; then
echo 'Usage: build-docker-image.sh <dockerFile> <dockerImageTag> [<dockerBuildArgs>...]' >&2
exit 1
fi
dockerFile="$1"
dockerTag="$2"
shift; shift
scripts="$(dirname "$0")"
"$scripts"/custom-timeout.sh 20 docker pull "$2" || true
echo "Building $2"
"$scripts"/custom-timeout.sh 30 docker build -f "$1" -t "$2" --cache-from "$2" .
"$scripts"/custom-timeout.sh 20 docker pull "${dockerTag}" || true
echo "Building $dockerTag"
"$scripts"/custom-timeout.sh 30 docker build "$@" -f "${dockerFile}" -t "${dockerTag}" --cache-from "${dockerTag}" .

View file

@ -15,13 +15,23 @@ elif [ -n "$TRAVIS_TAG" ]; then
tags+=("$TRAVIS_TAG" latest)
fi
ci/build-docker-image.sh docker/node/Dockerfile nanocurrency/nano
for tag in "${tags[@]}"; do
# Sanitize docker tag
# https://docs.docker.com/engine/reference/commandline/tag/
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
if [ "$tag" != "latest" ]; then
docker tag nanocurrency/nano nanocurrency/nano:"$tag"
for network in live beta; do
if [ "${network}" = 'live' ]; then
network_tag_suffix=''
else
network_tag_suffix="-${network}"
fi
"$scripts"/custom-timeout.sh 30 docker push nanocurrency/nano:"$tag"
docker_image_name="nanocurrency/nano${network_tag_suffix}"
ci/build-docker-image.sh docker/node/Dockerfile "$docker_image_name" --build-arg NETWORK="${network}"
for tag in "${tags[@]}"; do
# Sanitize docker tag
# https://docs.docker.com/engine/reference/commandline/tag/
tag="$(printf '%s' "$tag" | tr -c '[a-z][A-Z][0-9]_.-' -)"
if [ "$tag" != "latest" ]; then
docker tag "$docker_image_name" "${docker_image_name}:$tag"
fi
"$scripts"/custom-timeout.sh 30 docker push "${docker_image_name}:$tag"
done
done

View file

@ -1,35 +1,31 @@
FROM ubuntu:16.04
ENV BOOST_BASENAME=boost_1_66_0 \
BOOST_ROOT=/tmp/boost_install \
BOOST_URL=https://netix.dl.sourceforge.net/project/boost/boost/1.66.0/boost_1_66_0.tar.gz
ARG NETWORK=live
ENV BOOST_ROOT=/tmp/boost_install
ADD ci /tmp/ci
RUN apt-get update -qq && apt-get install -yqq \
build-essential \
cmake \
g++ \
wget && \
wget -qO ${BOOST_BASENAME}.tar.gz ${BOOST_URL} && \
tar xzf ${BOOST_BASENAME}.tar.gz && \
cd ${BOOST_BASENAME} && \
./bootstrap.sh && \
./b2 -d0 --prefix=${BOOST_ROOT} link=static install && \
rm -rf ${BOOST_BASENAME} && \
rm -f ${BOOST_BASENAME}.tar.gz && \
cd .. && \
mkdir /usr/share/raiblocks/
/tmp/ci/bootstrap_boost.sh -m
ADD ./ /tmp/src
RUN mkdir /tmp/build && \
cd /tmp/build && \
cmake /tmp/src -DBOOST_ROOT=${BOOST_ROOT} && \
cmake /tmp/src -DBOOST_ROOT=${BOOST_ROOT} -DACTIVE_NETWORK=rai_${NETWORK}_network && \
make rai_node && \
cd ..
cd .. && \
echo ${NETWORK} > /etc/nano-network
FROM ubuntu:16.04
COPY --from=0 /tmp/build/rai_node /usr/bin
COPY --from=0 /etc/nano-network /etc
COPY docker/node/entry.sh /entry.sh
COPY docker/node/config.json /usr/share/raiblocks/config.json
COPY docker/node/config /usr/share/raiblocks/config
RUN chmod +x /entry.sh
CMD ["/bin/bash", "/entry.sh"]

View file

@ -1,6 +1,42 @@
#!/bin/bash
network='live'
print_usage() {
echo 'build.sh [-h] [-n {live|beta|test}]'
}
while getopts 'hn:' OPT; do
case "${OPT}" in
h)
print_usage
exit 0
;;
n)
network="${OPTARG}"
;;
*)
print_usage >&2
exit 1
;;
esac
done
case "${network}" in
live)
network_tag=''
;;
test|beta)
network_tag="-${network}"
;;
*)
echo "Invalid network: ${network}" >&2
exit 1
;;
esac
REPO_ROOT=`git rev-parse --show-toplevel`
COMMIT_SHA=`git rev-parse --short HEAD`
pushd $REPO_ROOT
docker build -f docker/node/Dockerfile -t raiblocks-node:latest .
docker build --build-arg NETWORK="${network}" -f docker/node/Dockerfile -t raiblocks-node${network_tag}:latest .
popd

View file

@ -0,0 +1,67 @@
{
"version": "2",
"rpc_enable": "true",
"rpc": {
"address": "::ffff:0.0.0.0",
"port": "7076",
"enable_control": "true",
"frontier_request_limit": "16384",
"chain_request_limit": "16384"
},
"node": {
"version": "8",
"peering_port": "7075",
"bootstrap_fraction_numerator": "1",
"receive_minimum": "1000000000000000000000000",
"logging": {
"version": "2",
"ledger": "false",
"ledger_duplicate": "false",
"vote": "false",
"network": "true",
"network_message": "false",
"network_publish": "false",
"network_packet": "false",
"network_keepalive": "false",
"node_lifetime_tracing": "false",
"insufficient_work": "true",
"log_rpc": "true",
"bulk_pull": "false",
"work_generation_time": "true",
"log_to_cerr": "false",
"max_size": "16777216",
"rotation_size": "4194304",
"flush": "false"
},
"work_peers": "",
"preconfigured_peers": [
"rai-beta.raiblocks.net"
],
"preconfigured_representatives": [
"xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4",
"xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou",
"xrb_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p",
"xrb_3dmtrrws3pocycmbqwawk6xs7446qxa36fcncush4s1pejk16ksbmakis78m",
"xrb_3hd4ezdgsp15iemx7h81in7xz5tpxi43b6b41zn3qmwiuypankocw3awes5k",
"xrb_1awsn43we17c1oshdru4azeqjz9wii41dy8npubm4rg11so7dx3jtqgoeahy",
"xrb_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs",
"xrb_1hza3f7wiiqa7ig3jczyxj5yo86yegcmqk3criaz838j91sxcckpfhbhhra1"
],
"inactive_supply": "0",
"password_fanout": "1024",
"io_threads": "4",
"work_threads": "4",
"enable_voting": "true",
"bootstrap_connections": "16",
"callback_address": "",
"callback_port": "0",
"callback_target": "",
"lmdb_max_dbs": "128"
},
"opencl_enable": "false",
"opencl": {
"platform": "0",
"device": "0",
"threads": "1048576"
}
}

View file

@ -0,0 +1,67 @@
{
"version": "2",
"rpc_enable": "true",
"rpc": {
"address": "::ffff:0.0.0.0",
"port": "7076",
"enable_control": "true",
"frontier_request_limit": "16384",
"chain_request_limit": "16384"
},
"node": {
"version": "8",
"peering_port": "7075",
"bootstrap_fraction_numerator": "1",
"receive_minimum": "1000000000000000000000000",
"logging": {
"version": "2",
"ledger": "false",
"ledger_duplicate": "false",
"vote": "false",
"network": "true",
"network_message": "false",
"network_publish": "false",
"network_packet": "false",
"network_keepalive": "false",
"node_lifetime_tracing": "false",
"insufficient_work": "true",
"log_rpc": "true",
"bulk_pull": "false",
"work_generation_time": "true",
"log_to_cerr": "false",
"max_size": "16777216",
"rotation_size": "4194304",
"flush": "false"
},
"work_peers": "",
"preconfigured_peers": [
"rai-test.raiblocks.net"
],
"preconfigured_representatives": [
"xrb_3arg3asgtigae3xckabaaewkx3bzsh7nwz7jkmjos79ihyaxwphhm6qgjps4",
"xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou",
"xrb_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p",
"xrb_3dmtrrws3pocycmbqwawk6xs7446qxa36fcncush4s1pejk16ksbmakis78m",
"xrb_3hd4ezdgsp15iemx7h81in7xz5tpxi43b6b41zn3qmwiuypankocw3awes5k",
"xrb_1awsn43we17c1oshdru4azeqjz9wii41dy8npubm4rg11so7dx3jtqgoeahy",
"xrb_1anrzcuwe64rwxzcco8dkhpyxpi8kd7zsjc1oeimpc3ppca4mrjtwnqposrs",
"xrb_1hza3f7wiiqa7ig3jczyxj5yo86yegcmqk3criaz838j91sxcckpfhbhhra1"
],
"inactive_supply": "0",
"password_fanout": "1024",
"io_threads": "4",
"work_threads": "4",
"enable_voting": "true",
"bootstrap_connections": "16",
"callback_address": "",
"callback_port": "0",
"callback_target": "",
"lmdb_max_dbs": "128"
},
"opencl_enable": "false",
"opencl": {
"platform": "0",
"device": "0",
"threads": "1048576"
}
}

View file

@ -1,10 +1,27 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
mkdir -p ~/RaiBlocks
if [ ! -f ~/RaiBlocks/config.json ]; then
echo "Config File not found, adding default."
cp /usr/share/raiblocks/config.json ~/RaiBlocks/
network="$(cat /etc/nano-network)"
case "${network}" in
live|'')
network='live'
dirSuffix=''
;;
beta)
dirSuffix='Beta'
;;
test)
dirSuffix='Test'
;;
esac
nanodir="${HOME}/RaiBlocks${dirSuffix}"
mkdir -p "${nanodir}"
if [ ! -f "${nanodir}/config.json" ]; then
echo "Config File not found, adding default."
cp "/usr/share/raiblocks/config/${network}.json" "${nanodir}/config.json"
fi
/usr/bin/rai_node --daemon