Skip to content
Snippets Groups Projects
Commit 0815e969 authored by lexon's avatar lexon
Browse files

Revised distribution folder arch-->dist.

Added support for alpine
parent aa1c1283
No related branches found
No related tags found
No related merge requests found
Showing
with 433 additions and 0 deletions
# Pull base image.
FROM quay.io/eris/base:alpine
MAINTAINER Eris Industries <support@erisindustries.com>
#-----------------------------------------------------------------------------
# dependencies
RUN apk update && \
apk add g++ gmp-dev jq
#-----------------------------------------------------------------------------
# install tendermint
# set the repo and install tendermint -- should track vendored commit
ENV REPO_ALIAS github.com/tendermint/tendermint
ENV REPO github.com/eris-ltd/tendermint
#ENV COMMIT 4ee387d0770ed379e2d524f7077938517b38cd7c
ENV COMMIT working
# note, we want to lock in the same commit number
# as eris-db has vendored.
RUN mkdir -p $GOPATH/src/$REPO
WORKDIR $GOPATH/src/$REPO_ALIAS
RUN git clone --quiet https://$REPO . && \
git checkout --quiet $COMMIT && \
go build -o /usr/local/bin/tendermint ./cmd/tendermint
#-----------------------------------------------------------------------------
# install mint-client tools
# set the repo and install mint-client
ENV REPO github.com/eris-ltd/mint-client
ENV BRANCH master
RUN mkdir -p $GOPATH/src/$REPO
WORKDIR $GOPATH/src/$REPO
RUN git clone --quiet https://$REPO . && \
git checkout --quiet $BRANCH && \
go install ./... && \
mv $GOPATH/bin/mint* /usr/local/bin && \
mv ./mint-client /usr/local/bin/
#-----------------------------------------------------------------------------
# install erisdb
# set the repo and install erisdb
ENV REPO $GOPATH/src/github.com/eris-ltd/eris-db
COPY . $REPO
WORKDIR $REPO
RUN cd ./cmd/erisdb && go build -o /usr/local/bin/erisdb && cd ../..
#-----------------------------------------------------------------------------
# cleanup
RUN rm -rf $GOPATH/src/* && \
unset REPO && \
unset REPO_ALIAS && \
unset COMMIT && \
unset BRANCH
#-----------------------------------------------------------------------------
# start script
# install the wrapper/start script
COPY DOCKER/start.sh /usr/local/bin/erisdb-wrapper
#-----------------------------------------------------------------------------
# chain manager scripts and default mint config
ENV ECM_PATH /usr/local/lib/ecm
RUN mkdir -p $ECM_PATH
COPY DOCKER/chain_* $ECM_PATH/
COPY DOCKER/config.toml $ECM_PATH/
COPY DOCKER/version.sh $ECM_PATH/
#-----------------------------------------------------------------------------
# permission the directories
RUN chown -R eris /usr/local/bin
RUN chown -R eris $ECM_PATH
#-----------------------------------------------------------------------------
# root dir
# persist data, set user
VOLUME /home/$USER/.eris
WORKDIR /home/$USER/.eris
USER $USER
RUN mkdir -p /home/$USER/.eris/chains/tendermint
ENV TMROOT /home/$USER/.eris/chains/tendermint
# run tendermint
# ports: 1337:eris-db API; 46656:mint-peer; 46657:mint-rpc
EXPOSE 1337
EXPOSE 46656
EXPOSE 46657
CMD "erisdb-wrapper"
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
#!/bin/sh
if [ "$CIRCLE_BRANCH" ]
then
repo=`pwd`
else
base=github.com/eris-ltd/eris-db
repo=$GOPATH/src/$base
fi
branch=${CIRCLE_BRANCH:=master}
release_min=$(cat $repo/version/version.go | tail -n 1 | cut -d \ -f 4 | tr -d '"')
release_maj=$(echo $release_min | cut -d . -f 1-2)
start=`pwd`
image_base=quay.io/eris/erisdb
cd $repo
if [ "$branch" = "master" ]; then
docker build -t $image_base:latest -f DOCKER/Dockerfile .
docker tag $image_base:latest $image_base:$release_maj
docker tag $image_base:latest $image_base:$release_min
else
docker build -t $image_base:$release_min -f DOCKER/Dockerfile .
fi
cd $start
\ No newline at end of file
#! /bin/bash
echo "Running chain $CHAIN_ID (via ErisDB API)"
erisdb $TMROOT
#! /bin/bash
#-----------------------------------------------------------------------
# get genesis, seed, copy config
export MINTX_NODE_ADDR=$NODE_ADDR
# get genesis if not already
if [ ! -e "${CHAIN_DIR}/genesis.json" ]; then
# etcb chain (given by $NODE_ADDR)
REFS_CHAIN_ID=$(mintinfo genesis chain_id)
ifExit "Error fetching default chain id from $NODE_ADDR"
REFS_CHAIN_ID=$(echo "$REFS_CHAIN_ID" | tr -d '"') # remove surrounding quotes
echo "etcb chain: $REFS_CHAIN_ID"
# get the genesis.json for a refs chain from the /genesis rpc endpoint
# for a different chain, use etcb (ie namereg on the ref chain)
if [ "$CHAIN_ID" = "$REFS_CHAIN_ID" ] ; then
# grab genesis.json
mintinfo genesis > "${CHAIN_DIR}/genesis.json"
ifExit "Error fetching genesis.json from $NODE_ADDR"
else
# fetch genesis from etcb
GENESIS=$(mintinfo names "${CHAIN_ID}/genesis" data)
ifExit "Error fetching genesis.json for $CHAIN_ID: $GENESIS"
echo $GENESIS > "${CHAIN_DIR}/genesis.json"
SEED_NODE=$(mintinfo names "${CHAIN_ID}/seeds" data)
ifExit "Error grabbing seed node from $NODE_ADDR for $CHAIN_ID"
fi
fi
# copy in config if not already
if [ ! -e "${CHAIN_DIR}/config.toml" ]; then
echo "laying default config..."
mintconfig > $CHAIN_DIR/config.toml
ifExit "Error creating config"
if [ "$SEED_NODE" = "" ]; then
SEED_NODE=$P2P_ADDR
fi
if [ "$HOST_NAME" = "" ]; then
HOST_NAME=mint_user
fi
fi
# set seed node and host name
if [ "$SEED_NODE" != "" ]; then
echo "Seed node: $SEED_NODE"
# NOTE the NODE_ADDR must not have any slashes (no http://)
sed -i "s/^\(seeds\s*=\s*\).*\$/\1\"$SEED_NODE\"/" "${CHAIN_DIR}/config.toml"
ifExit "Error setting seed node in config.toml"
fi
if [ "$HOST_NAME" != "" ]; then
echo "Host name: $HOST_NAME"
sed -i "s/^\(moniker\s*=\s*\).*\$/\1\"$HOST_NAME\"/" "${CHAIN_DIR}/config.toml"
ifExit "Error setting host name in config.toml"
fi
#-----------------------------------------------------------------------
# would be nice if we could stop syncing once we're caught up ...
echo "Running mint in ${CHAIN_DIR}"
tendermint node --fast_sync
ifExit "Error running tendermint!"
#! /bin/bash
echo "your new chain, kind marmot: $CHAIN_ID"
# lay the genesis
# if it exists, just overwrite the chain id
if [ ! -f $CHAIN_DIR/genesis.json ]; then
if [ "$CSV" = "" ]; then
mintgen random --dir="$CHAIN_DIR" 1 $CHAIN_ID
ifExit "Error creating random genesis file"
else
mintgen known --csv="$CSV" $CHAIN_ID > $CHAIN_DIR/genesis.json
ifExit "Error creating genesis file from csv"
fi
else
# apparently just outputing to $CHAIN_DIR/genesis.json doesn't work so we copy
cat $CHAIN_DIR/genesis.json | jq .chain_id=\"$CHAIN_ID\" > genesis.json
cp genesis.json $CHAIN_DIR/genesis.json
fi
# if no config was given, lay one with the given options
if [ ! -f $CHAIN_DIR/config.toml ]; then
echo "running mintconfig $CONFIG_OPTS"
mintconfig $CONFIG_OPTS > $CHAIN_DIR/config.toml
else
echo "found config file:"
cat $CHAIN_DIR/config.toml
fi
# run the node.
# TODO: maybe bring back this stopping option if we think its useful
# tendermint node & last_pid=$! && sleep 1 && kill -KILL $last_pid
if [ $ERISDB_API ]; then
echo "Running chain $CHAIN_ID (via ErisDB API)"
erisdb $TMROOT
ifExit "Error starting erisdb"
else
echo Running chain $CHAIN_ID
tendermint node
ifExit "Error starting tendermint"
fi
#! /bin/bash
echo "registering $CHAIN_ID in the grand registry of marmot mayhem and marmalade"
# lay the genesis
# if it exists, just overwrite the chain id
if [ ! -f "$CHAIN_DIR/genesis.json" ]; then
"Could not find genesis file in $CHAIN_DIR. Did you run `eris chains new $CHAIN_ID`?"
exit 1
fi
echo "or less dramatically, registering $CHAIN_ID with the $ETCB_CHAIN_ID chain at $MINTX_NODE_ADDR from address $PUBKEY"
echo "NAME ${CHAIN_ID}_genesis"
cat $CHAIN_DIR/genesis.json
# register the genesis
RES=`mintx name --pubkey=$PUBKEY --name="${CHAIN_ID}/genesis" --data-file=$CHAIN_DIR/genesis.json --amt=10000 --fee=0 --sign --broadcast --chainID=$ETCB_CHAIN_ID --wait`
ifExit "$RES" "Error registering genesis with etcb_testnet"
echo $RES | grep "Incorrect"
if0Exit "$RES" "Error registering genesis with etcb_testnet"
echo $RES
echo "successfully registered genesis on etcb chain"
# register the seed/s
RES=`mintx name --pubkey=$PUBKEY --name="${CHAIN_ID}/seeds" --data="$NEW_P2P_SEEDS" --amt=10000 --fee=0 --sign --broadcast --chainID=$ETCB_CHAIN_ID --wait`
ifExit "$RES" "Error registering seeds with etcb_testnet"
echo $RES | grep "Incorrect"
if0Exit "$RES" "Error registering seeds with etcb_testnet"
echo $RES
echo "successfully registered seed on etcb chain"
#! /bin/bash
if [ $ERISDB_API ]; then
echo "Running chain $CHAIN_ID (via ErisDB API)"
erisdb $TMROOT
ifExit "Error starting erisdb"
else
echo Running chain $CHAIN_ID
tendermint node
ifExit "Error starting tendermint"
fi
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml
moniker = "eris_chains"
node_laddr = "0.0.0.0:46656"
seeds = ""
fast_sync = false
db_backend = "leveldb"
log_level = "debug"
rpc_laddr = "0.0.0.0:46657"
#! /bin/bash
ifExit(){
if [[ $? != 0 ]]; then
echo "ifExit"
echo "$1"
for var in "$@"
do
echo "$var"
done
exit 1
fi
}
if0Exit(){
if [[ $? == 0 ]]; then
echo "if0Exit"
echo "$1"
for var in "$@"
do
echo "$var"
done
exit 1
fi
}
export -f ifExit
export -f if0Exit
#------------------------------------------------
# set and export directories
if [ "$CHAIN_ID" = "" ]; then
echo "ecm requires CHAIN_ID be set"
exit 1
fi
# TODO: deal with chain numbers
# and eg. $CONTAINER_NAME
CHAIN_DIR="/home/$USER/.eris/chains/$CHAIN_ID"
# set the tendermint directory
TMROOT=$CHAIN_DIR
if [ ! -d "$CHAIN_DIR" ]; then
mkdir -p $CHAIN_DIR
ifExit "Error making root dir $CHAIN_DIR"
fi
# our root chain
if [ ! $ROOT_CHAIN_ID ]; then
ROOT_CHAIN_ID=etcb_testnet
fi
if [ ! $NODE_ADDR ]; then
NODE_ADDR=interblock.io:46657
fi
if [ ! $P2P_ADDR ]; then
P2P_ADDR=interblock.io:46656
fi
# where the etcb client scripts are
if [ ! $ECM_PATH ]; then
ECM_PATH=.
fi
#------------------------------------------------
# dump key files if they are in env vars
if [ -z "$KEY" ]
then
echo "No Key Given"
else
echo "Key Given. Writing priv_validator.json"
echo "$KEY" >> $CHAIN_DIR/priv_validator.json
fi
if [ -z "$GENESIS" ]
then
echo "No Genesis Given"
else
echo "Genesis Given. Writing genesis.json"
echo "$GENESIS" > $CHAIN_DIR/genesis.json
fi
if [ -z "$GENESIS_CSV" ]
then
echo "No Genesis_CSV Given"
else
echo "Genesis_CSV Given. Writing genesis.csv"
echo "$GENESIS_CSV" > $CHAIN_DIR/genesis.csv
fi
if [ -z "$CHAIN_CONFIG" ]
then
echo "No Chain Config Given"
else
echo "Chain Config Given. Writing config.toml"
echo "$CHAIN_CONFIG" > $CHAIN_DIR/config.toml
fi
if [ -z "$SERVER_CONFIG" ]
then
echo "No Server Config Given"
else
echo "Server Config Given. Writing server_conf.toml"
echo "$SERVER_CONFIG" > $CHAIN_DIR/server_conf.toml
fi
#------------------------------------------------
# export important vars
export TMROOT
export CHAIN_DIR
export NODE_ADDR
export P2P_ADDR
export ECM_PATH # set by Dockerfile
export MINTX_NODE_ADDR=$NODE_ADDR
export MINTX_SIGN_ADDR=keys:4767
# print the version
bash $ECM_PATH/version.sh
#-----------------------------------------------------------------------
# either we are fetching a chain for the first time,
# creating one from scratch, or running one we already have
CMD=$1
case $CMD in
"install" ) $ECM_PATH/chain_install.sh
;;
"new" ) $ECM_PATH/chain_new.sh
;;
"run" ) $ECM_PATH/chain_run.sh
;;
"register" ) $ECM_PATH/chain_register.sh
;;
*) echo "Enter a command for starting the chain (new, install, run, register)"
;;
esac
# json break
echo "ecm version 0.12.0"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment