Uploading edited files
This commit is contained in:
commit
1ca1194688
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@ -0,0 +1,41 @@
|
||||
FROM node:10-stretch-slim
|
||||
|
||||
# Install Dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install --no-install-recommends -y build-essential git libzmq3-dev python nginx curl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update
|
||||
RUN apt-get install ca-certificates -y
|
||||
RUN update-ca-certificates
|
||||
|
||||
# Install flosight
|
||||
WORKDIR /flosight
|
||||
ADD https://api.github.com/repos/oipwg/flocore-node/git/refs/heads/master flocore-node-version.json
|
||||
RUN git clone https://github.com/ranchimall/flocore-node
|
||||
ADD https://api.github.com/repos/oipwg/flosight-ui/git/refs/heads/master flosight-ui-version.json
|
||||
ADD https://api.github.com/repos/oipwg/flosight-api/git/refs/heads/master flosight-api-version.json
|
||||
RUN npm install ./flocore-node/
|
||||
RUN npm install flosight-ui flosight-api
|
||||
|
||||
# Setup Nginx
|
||||
RUN service nginx stop && rm /etc/nginx/nginx.conf
|
||||
WORKDIR /etc/nginx
|
||||
COPY nginx.conf .
|
||||
RUN service nginx start
|
||||
|
||||
WORKDIR /nginx
|
||||
COPY http-proxy.conf .
|
||||
|
||||
# Add flosight configs
|
||||
WORKDIR /flosight
|
||||
COPY start.sh .
|
||||
COPY flocore-node.json .
|
||||
|
||||
RUN mkdir /data
|
||||
RUN chmod 755 /flosight/start.sh
|
||||
|
||||
# Expose used ports
|
||||
EXPOSE 80 443 3001 7312 7313 17312 17313 17413 41289
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:3001/api/sync || exit 1
|
||||
CMD ["/flosight/start.sh"]
|
||||
32
flocore-node.json
Normal file
32
flocore-node.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "5.0.0-beta.44",
|
||||
"network": "livenet",
|
||||
"port": 3001,
|
||||
"services": [
|
||||
"address",
|
||||
"block",
|
||||
"db",
|
||||
"fee",
|
||||
"header",
|
||||
"mempool",
|
||||
"p2p",
|
||||
"timestamp",
|
||||
"transaction",
|
||||
"flosight-api",
|
||||
"flosight-ui",
|
||||
"web"
|
||||
],
|
||||
"datadir": "/data",
|
||||
"servicesConfig": {
|
||||
"flosight-api": {
|
||||
"disableRateLimiter": true,
|
||||
"routePrefix": "api",
|
||||
"cwdRequirePath": "node_modules/flosight-api"
|
||||
},
|
||||
"flosight-ui": {
|
||||
"routePrefix": "",
|
||||
"apiPrefix": "api",
|
||||
"cwdRequirePath": "node_modules/flosight-ui"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
http-proxy.conf
Normal file
14
http-proxy.conf
Normal file
@ -0,0 +1,14 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3001;
|
||||
proxy_read_timeout 90;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Proxy "";
|
||||
}
|
||||
}
|
||||
21
nginx.conf
Normal file
21
nginx.conf
Normal file
@ -0,0 +1,21 @@
|
||||
events {
|
||||
worker_connections 768;
|
||||
}
|
||||
|
||||
http {
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
include /data/nginx/*.conf;
|
||||
}
|
||||
96
start.sh
Normal file
96
start.sh
Normal file
@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
cd /flosight
|
||||
|
||||
# Use Env variables in Config
|
||||
## Change Network Config if needed
|
||||
echo "Setup configs..."
|
||||
if [ "$NETWORK" == "testnet" ]
|
||||
then
|
||||
sed -i 's/livenet/testnet/g' flocore-node.json
|
||||
fi
|
||||
if [ "$NETWORK" == "regtest" ]
|
||||
then
|
||||
sed -i 's/livenet/regtest/g' flocore-node.json
|
||||
fi
|
||||
## Add Seednode config for fcoin if needed
|
||||
if ! [ -z "$ADDNODE" ]
|
||||
then
|
||||
echo nodes="$ADDNODE" > /data/fcoin.conf
|
||||
fi
|
||||
## Add any custom config values
|
||||
if [ ! -z "$CUSTOM_FCOIN_CONFIG" ]
|
||||
then
|
||||
echo -e "${CUSTOM_FCOIN_CONFIG}" >> /data/fcoin.conf
|
||||
fi
|
||||
|
||||
## Download the Blockchain Bootstrap if set
|
||||
if [ ! -z "$BLOCKCHAIN_BOOTSTRAP" ] && [ "$(cat /data/bootstrap-url.txt)" != "$BLOCKCHAIN_BOOTSTRAP" ]
|
||||
then
|
||||
# download and extract a Blockchain boostrap
|
||||
echo 'Downloading Blockchain Bootstrap...'
|
||||
RUNTIME="$(date +%s)"
|
||||
curl -L $BLOCKCHAIN_BOOTSTRAP -o /data/bootstrap.tar.gz --progress-bar | tee /dev/null
|
||||
RUNTIME="$(($(date +%s)-RUNTIME))"
|
||||
echo "Blockchain Bootstrap Download Complete (took ${RUNTIME} seconds)"
|
||||
echo 'Extracting Bootstrap...'
|
||||
RUNTIME="$(date +%s)"
|
||||
tar -xzf /data/bootstrap.tar.gz -C /data
|
||||
RUNTIME="$(($(date +%s)-RUNTIME))"
|
||||
echo "Blockchain Bootstrap Extraction Complete! (took ${RUNTIME} seconds)"
|
||||
rm -f /data/bootstrap.tar.gz
|
||||
echo 'Erased Blockchain Bootstrap `.tar.gz` file'
|
||||
echo "$BLOCKCHAIN_BOOTSTRAP" > /data/bootstrap-url.txt
|
||||
ls /data
|
||||
fi
|
||||
|
||||
# Currently fcoin requires us to create these directories
|
||||
echo "Pregenerate fcoin directories"
|
||||
mkdir /data/blocks
|
||||
mkdir /data/testnet
|
||||
mkdir /data/testnet/blocks
|
||||
mkdir /data/regtest
|
||||
mkdir /data/regtest/blocks
|
||||
|
||||
# Nginx http config
|
||||
mkdir -p /data/nginx/
|
||||
cp /nginx/http-proxy.conf /data/nginx/http-proxy.conf
|
||||
|
||||
echo "Config setup complete!"
|
||||
|
||||
# Startup Nginx (since docker has it stopped at startup)
|
||||
echo "Starting Nginx..."
|
||||
service nginx start
|
||||
echo "Nginx Started."
|
||||
|
||||
# Initial Startup of Flosight
|
||||
echo "Starting FLO Explorer $NETWORK"
|
||||
./node_modules/flocore-node/bin/flocore-node start > /data/latest.log &
|
||||
# Store PID for later
|
||||
echo $! > /data/flosight.pid
|
||||
|
||||
# Allow to startup
|
||||
timeout 1m tail -n 100 -f /data/latest.log
|
||||
|
||||
# Initialize block sync check file
|
||||
curl --silent http://localhost:3001/api/status?q=getBestBlockHash > currentHealthCheck.log
|
||||
echo 'different' > previousHealthCheck.log
|
||||
|
||||
# Every 5 minutes
|
||||
while true; do
|
||||
# Check to see if the most recent block hash is the same as the last time we checked.
|
||||
if [ "$(cat previousHealthCheck.log)" == "$(cat currentHealthCheck.log)" ]
|
||||
then
|
||||
# Restart instance
|
||||
echo "NO NEW BLOCKS IN 5+ MINUTES - RESTARTING PROCESS"
|
||||
kill -2 $(cat /data/flosight.pid)
|
||||
wait $(cat /data/flosight.pid)
|
||||
./node_modules/flocore-node/bin/flocore-node start >> /data/latest.log &
|
||||
# Store PID for later
|
||||
echo $! > /data/flosight.pid
|
||||
fi
|
||||
# Wait 5 minutes before checking again
|
||||
timeout 5m tail -f /data/latest.log
|
||||
|
||||
mv currentHealthCheck.log previousHealthCheck.log
|
||||
curl --silent http://localhost:3001/api/status?q=getBestBlockHash > currentHealthCheck.log
|
||||
done;
|
||||
Loading…
Reference in New Issue
Block a user