Skip to content

Commit

Permalink
public server docker file update
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickwieth committed Aug 20, 2023
1 parent 06de00b commit ce724e5
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 38 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ FROM ignitehq/cli:v0.27.1

USER root
RUN apt-get -y -qq update && \
apt-get install -y -qq apt-transport-https curl wget unzip screen && \
apt-get install -y -qq apt-transport-https curl wget unzip screen bash jq && \
apt-get clean
#
# install jq to parse json within bash scripts
RUN curl -o /usr/local/bin/jq http://stedolan.github.io/jq/download/linux64/jq && \
chmod +x /usr/local/bin/jq
#RUN curl -o /usr/local/bin/jq https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 && \
# chmod +x /usr/local/bin/jq
#RUN jq #this will crash in case jq is not properly installed

# install correct go version
RUN wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
RUN tar -xvf go1.20.2.linux-amd64.tar.gz
RUN rm /usr/local/go -rf
RUN mv go /usr/local


USER tendermint
WORKDIR /home/tendermint
WORKDIR /home/tendermints

RUN export GOPATH=$HOME/go
RUN wget https://github.com/DecentralCardGame/go-faucet/archive/master.zip && \
Expand All @@ -36,7 +42,6 @@ RUN ignite chain init
RUN wget -O $HOME/.Cardchain/config/genesis.json "https://raw.githubusercontent.com/DecentralCardGame/Testnet/Testnet4/genesis.json"
RUN wget -O $HOME/.Cardchain/config/addrbook.json "https://raw.githubusercontent.com/DecentralCardGame/Testnet/Testnet4/addrbook.json"

RUN echo $HOME

RUN chmod +x ./docker-run.sh
ENTRYPOINT ./docker-run.sh
ENTRYPOINT bash docker-run.sh
36 changes: 17 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,27 @@ services:
build: .
command: ./docker-run.sh
volumes:
- /home/wieth:/home/tendermint/
- ./backup:/backup
- ./docker-run.sh:/home/tendermint/docker-run.sh
ports:
- 26657:26657
- 26658:26658
- 1317:1317
- 9090:9090
- 4500:4500

herd:
image: nginx:latest
container_name: herd
volumes:
- /etc/letsencrypt/live/cardchain.crowdcontrol.network/fullchain.pem:/etc/letsencrypt/live/cardchain.crowdcontrol.network/fullchain.pem
- /etc/letsencrypt/live/cardchain.crowdcontrol.network/privkey.pem:/etc/letsencrypt/live/cardchain.crowdcontrol.network/privkey.pem
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
- /etc/nginx/ssl/dhparam-4096.pem:/etc/nginx/ssl/dhparam-4096.pem
ports:
- 80:80
- 81:81
- 443:443
command: /bin/bash -c "exec nginx -g 'daemon off;'"
depends_on:
- blockchain

volumes:
database-data: # named volumes can be managed easier using docker-compose
# herd:
# image: nginx:latest
# container_name: herd
# volumes:
# - /etc/letsencrypt/live/cardchain.crowdcontrol.network/fullchain.pem:/etc/letsencrypt/live/cardchain.crowdcontrol.network/fullchain.pem
# - /etc/letsencrypt/live/cardchain.crowdcontrol.network/privkey.pem:/etc/letsencrypt/live/cardchain.crowdcontrol.network/privkey.pem
# - ./config/nginx.conf:/etc/nginx/conf.d/default.conf
# - /etc/nginx/ssl/dhparam-4096.pem:/etc/nginx/ssl/dhparam-4096.pem
# ports:
# - 80:80
# - 81:81
# - 443:443
# command: /bin/bash -c "exec nginx -g 'daemon off;'"
# depends_on:
# - blockchain
82 changes: 69 additions & 13 deletions docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,75 @@
#!/bin/bash

# TODO
if false && test -f "/var/blockchain/exported_genesis.json"; then
echo -e "'\033[0;31m' exported_genesis.json found - reloading from there'\033[0m'"
mkdir ~/.ignite/local-chains/Cardchain
cp /var/blockchain/exported_genesis.json ~/.ignite/local-chains/Cardchain/exported_genesis.json
cp /var/blockchain/binary_checksum.txt ~/.ignite/local-chains/Cardchain/
cp /var/blockchain/config_checksum.txt ~/.ignite/local-chains/Cardchain/
cp /var/blockchain/source_checksum.txt ~/.ignite/local-chains/Cardchain/
#set -eo pipefail

echo -e "\033[0;32mfasten your seatbelts\033[0m"
FAUCET_SECRET_KEY="0x6F1f5bd93f3D59d6eed1d5ec40E29C1821029759"
CHAIN_ID=Cardchain

if [ -z "$FAUCET_SECRET_KEY" ]
then
echo -e "\033[0;31mNO SECRET KEY FOR FAUCET CONFIGURED! \033[0m"
exit 1
fi

# empty blocks would be nice, but this doesn't start the faucet
#Cardchaind start --consensus.create_empty_blocks false
SEEDS=""
PEERS="[email protected]:26657"; \
sed -i.bak -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.Cardchain/config/config.toml

SNAP_RPCs=("http://crowd.rpc.t.stavr.tech:21207"
"https://cardchain-testnet.nodejumper.io:443"
"https://cardchain-rpc.acloud.pp.ua:443")

# for i in "${SNAP_RPCs[@]}"; do
# if curl --output /dev/null --silent --head --fail --connect-timeout 5 $i; then
# echo "URL exists: $i"
# SNAP_RPC=$i
# break
# else
# echo "not reachable $i"
# fi
# done

# if [ -z "$SNAP_RPC" ]
# then
# echo -e "\033[0;31mNo SNAP_RPC available\033[0m"
# fi

SNAP_RPC="http://lxgr.xyz:26657"
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height)
echo $LATEST_HEIGHT
BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo -e "\033[0;36mlatest height: $LATEST_HEIGHT \nblock height: $BLOCK_HEIGHT \ntrust hash: $TRUST_HASH \033[0m"

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.Cardchain/config/config.toml; \

# config pruning
indexer="kv"
pruning="custom"
pruning_keep_recent="100"
pruning_keep_every="0"
pruning_interval="10"

sed -i -e "s/^indexer *=.*/indexer = \"$indexer\"/" $HOME/.Cardchain/config/config.toml
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.Cardchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.Cardchain/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.Cardchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.Cardchain/config/app.toml

echo -e "\033[0;32mstarting faucet \033[0m"
sed -i -e "s/^SECRET_KEY *=.*/SECRET_KEY = \"$FAUCET_SECRET_KEY\"/" go-faucet-master/.env
cd go-faucet-master
./go-faucet &
echo -e "\033[0;31mfaucet adress: \033[0;36m $(Cardchaind keys show alice --address) \033[0;31m must be registered!\033[0m"

./ignite chain serve
echo -e "\033[0;32mstarting Blockchain\033[0m"
Cardchaind start

# the following line is evaluated if csd is terminated via pkill (docker-stop-and-export.sh)
Cardchaind export > ~/.ignite/local-chains/Cardchain/exported_genesis.json
# backup area (this will be executed if the Cardchaind process is killed)
now=$(date +"%d.%m.%Y")
Cardchaind export > /backup/genesis$now.json
echo "BACKUP should be in /backup/genesis$now"

0 comments on commit ce724e5

Please sign in to comment.