Compare commits

...

10 Commits

Author SHA1 Message Date
Vivek Teega
e5cf6ca92f
Update README.md
Some checks failed
Docker Build dev / build (push) Has been cancelled
Docker Build main / build (push) Has been cancelled
2023-06-20 14:39:19 +05:30
Vivek Teega
61a0f1dbc1 Changed the name of bootstrap file 2023-06-20 14:21:35 +05:30
Sai Raj
ea3bfb0b60
Update Dockerfile 2023-05-05 13:27:56 +05:30
Vivek Teega
b99bc76b1f
Update README.md 2023-02-16 18:20:35 +05:30
Vivek Teega
81e3490138
Update README.md 2023-02-16 18:18:31 +05:30
sairajzero
6c800d8fc1 Auto-restart when unhealthy 2023-02-07 22:13:31 +05:30
sairajzero
b880a1d03a Updating docker files 2023-02-05 04:12:38 +05:30
sairajzero
81c8e6ee24 Update dev_Dockerfile 2023-01-27 22:58:29 +05:30
Sai Raj
d7a966f514
Create build-publish-dev.yml 2023-01-11 00:02:52 +05:30
Sai Raj
1d61c9a487
Update README.md 2023-01-10 23:47:50 +05:30
6 changed files with 78 additions and 42 deletions

28
.github/workflows/build-publish-dev.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: Docker Build dev
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: docker login
env:
DOCKER_USER: ${{secrets.DOCKER_HUB_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_HUB_PASS}}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Build the Docker image
run: docker build . --file dev_Dockerfile --tag ranchimallfze/flosight:dev
- name: Docker Push
run: docker push ranchimallfze/flosight:dev

View File

@ -10,12 +10,10 @@ RUN update-ca-certificates
# Install flosight
WORKDIR /flosight
ADD https://api.github.com/repos/ranchimall/flocore-node/git/refs/heads/master flocore-node-version.json
RUN echo "flosight"
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 node-fetch@2
RUN npm install node-fetch@2
# Setup Nginx
RUN service nginx stop && rm /etc/nginx/nginx.conf
@ -39,4 +37,4 @@ RUN chmod 755 /flosight/start.sh
EXPOSE 80 443 3001 7312 7313 17312 17313 17413 41289
HEALTHCHECK CMD node healthcheck.js
CMD ["/flosight/start.sh"]
CMD ["/flosight/start.sh"]

View File

@ -6,9 +6,21 @@
```
docker volume create flosight
docker run -d --name=flosight -p 9200:80 --mount source=flosight,target=/data --env NETWORK=mainnet --env ADDNODE=ramanujam.ranchimall.net --env BLOCKCHAIN_BOOTSTRAP=https://bootstrap.ranchimall.net/data.tar.gz ranchimallfze/flosight:github
docker run -d --name=flosight -p 9200:80 --mount source=flosight,target=/data --env NETWORK=mainnet --env ADDNODE=ramanujam.ranchimall.net --env BLOCKCHAIN_BOOTSTRAP=https://bootstrap.ranchimall.net/flosight-bootstrap.tar.gz ranchimallfze/flosight:github
docker logs --follow --tail 500 flosight
```
If you want flosight to automatically start after your server/computer restarts, then add restart policy **--restart=always**
```
docker run -d --restart=always --name=flosight -p 9200:80 --mount source=flosight,target=/data --env NETWORK=mainnet --env ADDNODE=ramanujam.ranchimall.net --env BLOCKCHAIN_BOOTSTRAP=https://bootstrap.ranchimall.net/flosight-bootstrap.tar.gz ranchimallfze/flosight:github
```
If you want to change the restart policy of an existing container
```
docker update --restart=always <container>
```
Open the page http://localhost:8080/api/sync to view the sync status (available API endpoints). After sync is at 100%, you can open the page http://localhost:8080. If you open the homepage while it is still syncing, you will quickly get rate limited, as the UI makes a request for every block update that comes in (this is a bug that may be fixed at some point in the future).
@ -16,9 +28,9 @@ Open the page http://localhost:8080/api/sync to view the sync status (available
## Environment Variables
Flo Explorer uses Environment Variables to allow for configuration settings. You set the Env Variables in your docker run startup command. Here are the config settings offered by this image.
NETWORK: [mainnet|testnet] The Flo network you wish to run the Flo Explorer on (Default mainnet).
ADDNODE: [ip-address] An IP address of a Flo node to be used as a source of blocks. This is useful if you are running isolated networks, or if you are having a hard time connecting to the network.
CUSTOM_FCOIN_CONFIG: [String] A string (seperated with \n to split lines lines) of extra config variables to add to fcoin.conf (fcoin is the internal Flo Fullnode for the Flo Explorer)
* NETWORK: [mainnet|testnet] The Flo network you wish to run the Flo Explorer on (Default mainnet).
* ADDNODE: [ip-address] An IP address of a Flo node to be used as a source of blocks. This is useful if you are running isolated networks, or if you are having a hard time connecting to the network.
* CUSTOM_FCOIN_CONFIG: [String] A string (seperated with \n to split lines lines) of extra config variables to add to fcoin.conf (fcoin is the internal Flo Fullnode for the Flo Explorer)
## Instructions to build the image

View File

@ -10,12 +10,10 @@ RUN update-ca-certificates
# Install flosight
WORKDIR /flosight
ADD https://api.github.com/repos/ranchimall/flocore-node/git/refs/heads/master flocore-node-version.json
RUN git clone -b dev 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 node-fetch@2
RUN npm install github:ranchimall/flosight-ui#dev github:ranchimall/flosight-api#dev
RUN npm install node-fetch@2
# Setup Nginx
RUN service nginx stop && rm /etc/nginx/nginx.conf

View File

@ -1,7 +1,12 @@
const fs = require('fs');
const fetch = require('node-fetch');
const URL = 'http://localhost:3001';
const STATUS_FILE = 'healthcheck.status',
READY_FILE = 'healthcheck.ready',
LOG_FILE = 'healthcheck.log';
const checks = [];
//Check if UI is working and is type HTML
@ -72,15 +77,18 @@ checks.push(function check_lastBlock() {
Promise.all(checks.map(c => c())).then(results => {
let reasons = results.filter(r => r !== true);
if (!reasons.length) {
console.debug("HEALTHY");
fs.writeFileSync(STATUS_FILE, "HEALTHY");
fs.writeFileSync(READY_FILE, "1"); //Indicate the node has reached healthy status atleast once
process.exit(0);
} else {
console.debug("UNHEALTHY");
console.debug(reasons);
fs.writeFileSync(STATUS_FILE, "UNHEALTHY");
let reason_log = `${new Date().toJSON()}:FAIL: ${JSON.stringify(reasons)}\n`;
fs.writeFileSync(LOG_FILE, reason_log, { flag: 'a' });
process.exit(1);
}
}).catch(err => {
console.debug("ERROR");
console.error(err);
fs.writeFileSync(STATUS_FILE, "ERROR");
let err_log = `${new Date().toJSON()}:ERROR: ${err}\n`;
fs.writeFileSync(LOG_FILE, err_log, { flag: 'a' });
process.exit(1);
})

View File

@ -29,15 +29,15 @@ 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
curl -L $BLOCKCHAIN_BOOTSTRAP -o /data/flosight-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
tar -xzf /data/flosight-bootstrap.tar.gz -C /data
RUNTIME="$(($(date +%s)-RUNTIME))"
echo "Blockchain Bootstrap Extraction Complete! (took ${RUNTIME} seconds)"
rm -f /data/bootstrap.tar.gz
rm -f /data/flosight-bootstrap.tar.gz
echo 'Erased Blockchain Bootstrap `.tar.gz` file'
echo "$BLOCKCHAIN_BOOTSTRAP" > /data/bootstrap-url.txt
ls /data
@ -66,31 +66,23 @@ echo "Nginx Started."
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
echo $! > flosight.pid
# 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
# Check the health of the node and restart if needed
if [ "$(cat healthcheck.status)" == "UNHEALTHY" ] && [ "$(cat healthcheck.ready)" == "1" ]; then
# Restart instance
echo "$(date): UNHEALTHY - RESTARTING PROCESS" >> /data/latest.log
kill -2 $(cat flosight.pid)
wait $(cat flosight.pid)
./node_modules/flocore-node/bin/flocore-node start >> /data/latest.log &
# Store PID for later
echo $! > flosight.pid
fi
done;