commit
97e5c9efa9
@ -0,0 +1,20 @@ |
||||
FROM alpine |
||||
|
||||
RUN apk add --no-cache bash libstdc++ gmp-dev libc6-compat && ln -s libcrypto.so.1.1 /lib/libcrypto.so.10 |
||||
|
||||
# default base port, rpc port and rest port |
||||
EXPOSE 9000/tcp 14555/tcp 6000/tcp |
||||
|
||||
VOLUME ["/harmony/db", "/harmony/log"] |
||||
|
||||
# Default BN for cello |
||||
ENV BN_MA "/ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv,/ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9" |
||||
ENV NODE_PORT "9000" |
||||
ENV NODE_ACCOUNT_ID "" |
||||
|
||||
ENTRYPOINT ["/bin/run"] |
||||
WORKDIR /harmony |
||||
|
||||
COPY run /bin/run |
||||
COPY libbls384.so libmcl.so /lib/ |
||||
COPY harmony /bin/ |
@ -0,0 +1,67 @@ |
||||
#!/bin/bash |
||||
|
||||
DOCKER_IMAGE=harmonyone/node:master |
||||
|
||||
function usage() |
||||
{ |
||||
echo "usage: $(basename $0) [-p base_port] account_id" |
||||
exit 1 |
||||
} |
||||
|
||||
if [ -z "$(which docker)" ]; then |
||||
echo "docker is not installed." |
||||
echo "Please check https://docs.docker.com/install/ to get docker installed." |
||||
exit 1 |
||||
fi |
||||
|
||||
port_base= |
||||
|
||||
while getopts "p:" opt; do |
||||
case "$opt" in |
||||
p) port_base="$OPTARG";; |
||||
*) usage;; |
||||
esac |
||||
done |
||||
|
||||
shift $(($OPTIND-1)) |
||||
|
||||
account_id=$1 |
||||
|
||||
if [ -z "$account_id" ]; then |
||||
echo "Please provide account id" |
||||
usage |
||||
fi |
||||
|
||||
if [ -z "$port_base" ]; then |
||||
echo "Using default port: 9000" |
||||
port_base=9000 |
||||
fi |
||||
|
||||
if [ "$port_base" -lt 4000 ]; then |
||||
echo "port base cannot be less than 4000" |
||||
exit 1 |
||||
fi |
||||
|
||||
if [ "$port_base" -gt 59900 ]; then |
||||
echo "port base cannot be greater than 59900" |
||||
exit 1 |
||||
fi |
||||
|
||||
port_rest=$(( $port_base - 3000 )) |
||||
port_rpc=$(( $port_base + 5555 )) |
||||
# Pull latest image |
||||
docker pull $DOCKER_IMAGE |
||||
# Stop running container |
||||
docker rm -v -f harmony-$account_id-$port_base |
||||
docker run -it -d \ |
||||
--name harmony-$account_id-$port_base \ |
||||
-p $port_base:$port_base -p $port_rest:$port_rest -p $port_rpc:$port_rpc \ |
||||
-e NODE_PORT=$port_base \ |
||||
-e NODE_ACCOUNT_ID=$account_id \ |
||||
--mount type=volume,source=data-$port_base,destination=/harmony/db \ |
||||
--mount type=volume,source=log-$port_base,destination=/harmony/log \ |
||||
$DOCKER_IMAGE |
||||
|
||||
echo "Please run \`docker logs -f harmony-$account_id-$port_base\` to check console logs" |
||||
|
||||
# vim: ai ts=2 sw=2 et sts=2 ft=sh |
@ -0,0 +1,36 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# https://www.linuxjournal.com/content/validating-ip-address-bash-script |
||||
function valid_ip() |
||||
{ |
||||
local ip=$1 |
||||
local stat=1 |
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then |
||||
OIFS=$IFS |
||||
IFS='.' |
||||
ip=($ip) |
||||
IFS=$OIFS |
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ |
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] |
||||
stat=$? |
||||
fi |
||||
return $stat |
||||
} |
||||
|
||||
PUB_IP=$(wget -qO- https://api.ipify.org) |
||||
if valid_ip $PUB_IP; then |
||||
echo "MYIP = $PUB_IP" |
||||
else |
||||
echo "NO valid public IP found: $PUB_IP" |
||||
exit 1 |
||||
fi |
||||
|
||||
if [ -z "$NODE_ACCOUNT_ID" ]; then |
||||
echo "No account id." |
||||
exit 2 |
||||
fi |
||||
|
||||
harmony -log_folder log -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -account_index $NODE_ACCOUNT_ID |
||||
|
||||
# vim: ai ts=2 sw=2 et sts=2 ft=sh |
Loading…
Reference in new issue