Compare commits
13 Commits
main
...
upgrade/sy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90b55f5462 | ||
|
|
61f3e95e9b | ||
|
|
54c07cf30f | ||
|
|
d2813c3b6f | ||
|
|
f82522b114 | ||
|
|
34223a550a | ||
|
|
34eb02d070 | ||
|
|
c2dc3bd3cb | ||
|
|
69c4721f19 | ||
|
|
93be49b7a7 | ||
|
|
48ca59d104 | ||
|
|
eb8fb57863 | ||
|
|
76a911542b |
12
.env.example
12
.env.example
@ -1,12 +0,0 @@
|
||||
BACKEND_IMAGE=vivekteega/blockbook:1.0.0
|
||||
FRONTEND_IMAGE=vivekteega/blockbook:1.0.0
|
||||
BACKEND_CONTAINER_NAME=blockbook-backend
|
||||
FRONTEND_CONTAINER_NAME=blockbook-frontend
|
||||
BACKEND_BOOTSTRAP_FILE=/path/to/your/bootstrap-blockbook-flo-mainnet-backend.tar.gz # Set to empty string if not provided
|
||||
FRONTEND_BOOTSTRAP_FILE=/path/to/your/bootstrap-blockbook-flo-mainnet-frontend.tar.gz # Set to empty string if not provided
|
||||
BACKEND_BOOTSTRAP_URL=/path/to/your/bootstrap-blockbook-flo-mainnet-backend.tar.gz # Set to empty string if not provided
|
||||
FRONTEND_BOOTSTRAP_URL=/path/to/your/bootstrap-blockbook-flo-mainnet-frontend.tar.gz # Set to empty string if not provided
|
||||
BACKEND_PORT_1=38366
|
||||
BACKEND_PORT_2=8066
|
||||
FRONTEND_PORT_1=9166
|
||||
FRONTEND_PORT_2=9066
|
||||
36
.github/workflows/docker-image.yml
vendored
36
.github/workflows/docker-image.yml
vendored
@ -1,36 +0,0 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "upgrade/separate-images/ci-cd-testing" ]
|
||||
pull_request:
|
||||
branches: [ "upgrade/separate-images/ci-cd-testing" ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/blockbook:1.0.0
|
||||
|
||||
- name: Log out from Docker Hub
|
||||
run: docker logout
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1 @@
|
||||
.env
|
||||
playbook.yml
|
||||
.env
|
||||
43
Dockerfile
Normal file → Executable file
43
Dockerfile
Normal file → Executable file
@ -1,21 +1,32 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Backend
|
||||
COPY ./deb-files/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb /opt/backend.deb
|
||||
COPY ./deb-files/blockbook-flo_0.4.0_amd64.deb /opt/blockbook.deb
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && apt install -y /opt/backend.deb /opt/blockbook.deb curl && \
|
||||
sed -i 's/daemon=1/daemon=0/' /opt/coins/nodes/flo/flo.conf && \
|
||||
sed -i '/rpcport=8066/a rpcallowip=0.0.0.0/0' /opt/coins/nodes/flo/flo.conf && \
|
||||
echo "addnode=ramanujam.ranchimall.net" >> /opt/coins/nodes/flo/flo.conf && \
|
||||
echo "addnode=turing.ranchimall.net" >> /opt/coins/nodes/flo/flo.conf && \
|
||||
echo "addnode=stevejobs.ranchimall.net" >> /opt/coins/nodes/flo/flo.conf && \
|
||||
echo "addnode=brahmagupta.ranchimall.net" >> /opt/coins/nodes/flo/flo.conf && \
|
||||
echo "addnode=feynman.ranchimall.net" >> /opt/coins/nodes/flo/flo.conf
|
||||
# Copying files to the container
|
||||
COPY /deb-files-mainnet/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb /tmp/backend-flo.deb
|
||||
COPY /deb-files-mainnet/blockbook-flo_0.4.0_amd64.deb /tmp/blockbook-flo.deb
|
||||
|
||||
WORKDIR /opt/coins/blockbook/flo
|
||||
# Installing Blockbook and Supervisor
|
||||
RUN apt-get update && \
|
||||
apt-get install -y /tmp/backend-flo.deb /tmp/blockbook-flo.deb supervisor wget && \
|
||||
rm /tmp/backend-flo.deb /tmp/blockbook-flo.deb && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Execution
|
||||
COPY ./entrypoint.sh /opt/entrypoint.sh
|
||||
RUN chmod +x /opt/entrypoint.sh
|
||||
ENTRYPOINT ["/opt/entrypoint.sh"]
|
||||
# Copying conf file after installing supervisor to fix scripting error
|
||||
COPY /deb-files-mainnet/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
COPY start.sh /tmp
|
||||
|
||||
# Configuring backend as forground process under supervisord
|
||||
RUN sed -i "s/daemon=1/daemon=0/g" /opt/coins/nodes/flo/flo.conf &&\
|
||||
chmod +x /tmp/start.sh
|
||||
|
||||
EXPOSE 9166
|
||||
|
||||
VOLUME /opt/coins
|
||||
|
||||
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||
CMD ["/bin/bash", "-c", "/tmp/start.sh"]
|
||||
|
||||
# check logs
|
||||
# tail -f /opt/coins/data/flo/backend/debug.log
|
||||
# tail -f /opt/coins/blockbook/flo/logs/blockbook.INFO
|
||||
|
||||
39
Dockerfile-testnet
Normal file
39
Dockerfile-testnet
Normal file
@ -0,0 +1,39 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Copying files to the container
|
||||
# COPY /deb-files-testnet/peers.dat /tmp
|
||||
COPY /deb-files-testnet/backend-flo-testnet_0.15.1.1-satoshilabs-1_amd64.deb /tmp/backend-flo.deb
|
||||
COPY /deb-files-testnet/blockbook-flo-testnet_0.4.0_amd64.deb /tmp/blockbook-flo.deb
|
||||
|
||||
# Installing Blockbook and Supervisor
|
||||
RUN apt-get update && \
|
||||
apt-get install -y /tmp/backend-flo.deb /tmp/blockbook-flo.deb supervisor wget && \
|
||||
rm /tmp/backend-flo.deb /tmp/blockbook-flo.deb && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copying conf file after installing supervisor to fix scripting error
|
||||
COPY /deb-files-testnet/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
COPY start.sh /tmp
|
||||
|
||||
# Configuring backend as forground process and adding nodes to sync backend
|
||||
RUN sed -i "s/daemon=1/daemon=0/g" /opt/coins/nodes/flo_testnet/flo_testnet.conf && \
|
||||
sed -i '$a addnode=ramanujam.ranchimall.net\naddnode=turing.ranchimall.net\naddnode=stevejobs.ranchimall.net\naddnode=brahmagupta.ranchimall.net\naddnode=feynman.ranchimall.net' /opt/coins/nodes/flo_testnet/flo_testnet.conf && \
|
||||
chmod +x /tmp/start.sh
|
||||
|
||||
# RUN cd /opt/coins/nodes/flo_testnet && \
|
||||
# /opt/coins/nodes/flo_testnet/bin/flod --testnet -datadir=/opt/coins/data/flo_testnet/backend -conf=/opt/coins/nodes/flo_testnet/flo_testnet.conf -pid=/run/flo_testnet/flo_testnet.pid
|
||||
|
||||
# RUN mv /tmp/peers.dat /opt/coins/data/flo_testnet/backend/testnet4/peers.dat
|
||||
|
||||
EXPOSE 19166
|
||||
|
||||
VOLUME /opt/coins
|
||||
|
||||
# CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
|
||||
CMD ["/bin/bash", "-c", "/tmp/start.sh"]
|
||||
|
||||
# check logs
|
||||
# tail -f /opt/coins/data/flo_testnet/backend/testnet4/debug.log
|
||||
# tail -f /opt/coins/blockbook/flo_testnet/logs/blockbook.INFO
|
||||
176
README.md
176
README.md
@ -1,48 +1,166 @@
|
||||
# Blockbook docker
|
||||
# Blockbook Docker (Single Container)
|
||||
|
||||
## Roadmap for upgrade
|
||||
This guide will help you build and run the Docker image for Blockbook Mainnet and Testnet, which is based on Ubuntu 22.04 and includes both backend and frontend components in a single container.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Docker installed on your machine](https://docs.docker.com/engine/install/).
|
||||
- Clone or download the repository to your local machine.
|
||||
|
||||
- [ ] How to set this up in production
|
||||
- [ ] Think of how Blockbook container will detect the status of backend container
|
||||
- [ ] Figure out if multiple volume path need to be mounted
|
||||
- [ ] See if creating a new network for both the containers will be a good option.
|
||||
---
|
||||
- [X] [Unable to build frontend separately since having backend package installed is a dependency] Create separate images for both backend and blockbook.
|
||||
- [X] Attach the same volume to both the running containers of the images.
|
||||
|
||||
## Quickstart
|
||||
# Mainnet
|
||||
|
||||
To run the services using this file create a .env file using .env.example file, fill info and run the following command in the same directory:
|
||||
Steps to build the Docker image for Mainnet.
|
||||
|
||||
```
|
||||
sudo docker-compose up -d
|
||||
- **Building the Docker Image**
|
||||
|
||||
Navigate to the directory where the repository is cloned and build the Docker image:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/ranchimall/blockbook-docker
|
||||
cd blockbook-docker
|
||||
docker build -f Dockerfile -t ranchimall/blockbook-mainnet:1.0.0 .
|
||||
```
|
||||
|
||||
- **Running the Docker Container**
|
||||
|
||||
Create a named volume for persistent storage:
|
||||
|
||||
```sh
|
||||
docker volume create mainnet
|
||||
```
|
||||
|
||||
Run the Docker container in detached mode and map port `9166` of the container to port `9166` (or any other port) on the host machine (`-p host-port:container-port`):
|
||||
|
||||
```sh
|
||||
docker run -d -e ZIP=false -e NETWORK=mainnet --name blockbook-mainnet -p 9166:9166 --mount source=mainnet,target=/opt/coins ranchimall/blockbook-mainnet:1.0.0
|
||||
```
|
||||
|
||||
- **Accessing the Frontend**
|
||||
|
||||
Once the Docker container is running, you can access the frontend of the application by navigating to: [https://localhost:9166](https://localhost:9166) in your web browser.
|
||||
|
||||
- **Accessing Logs**
|
||||
|
||||
To check the logs, you can access the container shell and use the `tail` command:
|
||||
|
||||
```sh
|
||||
docker exec -it blockbook-mainnet bash
|
||||
```
|
||||
|
||||
To view the logs of the backend and frontend, run:
|
||||
|
||||
```sh
|
||||
# Backend logs
|
||||
tail -f /opt/coins/data/flo/backend/debug.log
|
||||
|
||||
# Frontend logs
|
||||
tail -f /opt/coins/blockbook/flo/logs/blockbook.INFO
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Testnet
|
||||
|
||||
Steps to build the Docker image for Testnet.
|
||||
|
||||
- **Building the Docker Image**
|
||||
|
||||
Navigate to the directory where the repository is cloned or downloaded and build the Docker image:
|
||||
|
||||
```sh
|
||||
cd blockbook-docker
|
||||
docker build -f Dockerfile-testnet -t ranchimall/blockbook-testnet:1.0.0 .
|
||||
```
|
||||
|
||||
- **Running the Docker Container**
|
||||
|
||||
Create a named volume for persistent storage:
|
||||
|
||||
```sh
|
||||
docker volume create testnet
|
||||
```
|
||||
|
||||
Run the Docker container in detached mode and map port `19166` of the container to port `19166` (or any other port) on the host machine (`-p host-port:container-port`):
|
||||
|
||||
```sh
|
||||
docker run -d -e ZIP=false -e NETWORK=testnet --name blockbook-testnet -p 19166:19166 --mount source=testnet,target=/opt/coins ranchimall/blockbook-testnet:1.0.0
|
||||
```
|
||||
|
||||
- **Accessing the Frontend**
|
||||
|
||||
Once the Docker container is running, you can access the frontend of the application by navigating to: [https://localhost:19166](https://localhost:19166) in your web browser.
|
||||
|
||||
- **Accessing Logs**
|
||||
|
||||
To check the logs, you can access the container shell and use the `tail` command:
|
||||
|
||||
```sh
|
||||
docker exec -it blockbook-testnet bash
|
||||
```
|
||||
|
||||
To view the logs of the backend and frontend, run:
|
||||
|
||||
```sh
|
||||
# Backend logs
|
||||
tail -f /opt/coins/data/flo_testnet/backend/testnet4/debug.log
|
||||
|
||||
# Frontend logs
|
||||
tail -f /opt/coins/blockbook/flo_testnet/logs/blockbook.INFO
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Blockbook uses environment variables to allow for configuration settings. You set the environment 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 Blockbook on.
|
||||
- ZIP: [true|false] To download the bootstrap data or not to speed up the syncing of blocks, which will be reflected in Blockbook.
|
||||
- TESTNET_ZIP_URL: The URL for Testnet to download the zip for bootstrapping Blockbook (Testnet).
|
||||
- MAINNET_ZIP_URL: The URL for Mainnet to download the zip for bootstrapping Blockbook (Mainnet).
|
||||
|
||||
You can use the `--env-file` flag to pass these environments through a file during runtime. Create a `.env` file in the same directory as your project, using the `.env.example` file as a guide. Then, run your app with the following command to load the environment variables from the file:
|
||||
```sh
|
||||
#to run mainnet add mainnet Environment Variables.
|
||||
docker run -d --env-file .env --name blockbook-mainnet -p 9166:9166 --mount source=mainnet,target=/opt/coins ranchimall/blockbook-mainnet:1.0.0
|
||||
|
||||
#to run testnet add testnet Environment Variables.
|
||||
docker run -d --env-file .env -name blockbook-testnet -p 19166:19166 --mount source=testnet,target=/opt/coins ranchimall/blockbook-testnet:1.0.0
|
||||
```
|
||||
|
||||
## Running blockbook manually
|
||||
## Additional Commands
|
||||
|
||||
```
|
||||
- **Stopping the Docker Container:**
|
||||
|
||||
docker volume create blockbook
|
||||
To stop the container, use:
|
||||
|
||||
docker network create blockbook
|
||||
```sh
|
||||
docker stop <containername>
|
||||
```
|
||||
|
||||
# Run backend in "it" mode for testing
|
||||
docker run -it --name blockbook-backend --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 --network=blockbook vivekteega/blockbook:1.0.0 backend
|
||||
- **Removing the Docker Container:**
|
||||
|
||||
# Run backend in daemon mode for production
|
||||
docker run -d --name blockbook-backend --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 --network=blockbook vivekteega/blockbook:1.0.0 backend
|
||||
To remove the container, use:
|
||||
|
||||
# Run backend in daemon mode for production with Bootstrap
|
||||
docker run -d --name blockbook-backend --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 --network=blockbook --env BOOTSTRAP_URL=https://bootstrap.ranchimall.net/blockbook-flo-backend1.tar.gz vivekteega/blockbook:1.0.0 backend
|
||||
```sh
|
||||
docker rm <containername>
|
||||
```
|
||||
|
||||
- **Removing the Docker Image:**
|
||||
|
||||
# Run frontend in "it" mode for testing
|
||||
docker run -it --name blockbook-frontend --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 --network=blockbook vivekteega/blockbook:1.0.0 frontend 172.20.0.2
|
||||
To remove the image, use:
|
||||
|
||||
# Run frontend in daemon mode for production
|
||||
docker run -d --name blockbook-frontend --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 --network=blockbook vivekteega/blockbook:1.0.0 frontend 172.20.0.2
|
||||
```sh
|
||||
docker rmi <imagename>
|
||||
```
|
||||
|
||||
# Bootstrap
|
||||
docker run -d --name blockbook-frontend --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 --network=blockbook --env BOOTSTRAP_URL=https://bootstrap.ranchimall.net/blockbook-flo-frontend.tar.gz vivekteega/blockbook:1.0.0 frontend 172.20.0.2
|
||||
Replace `<imagename>` and `<containername>` with the actual image name and container name or ID, respectively.
|
||||
|
||||
```
|
||||
## Troubleshooting
|
||||
|
||||
- Ensure that no other application is using port `9166` or `19166` on your host machine.
|
||||
- If you encounter issues, check the Docker container logs:
|
||||
|
||||
```sh
|
||||
docker logs <containername>
|
||||
```
|
||||
Binary file not shown.
Binary file not shown.
37
deb-files-mainnet/supervisord.conf
Normal file
37
deb-files-mainnet/supervisord.conf
Normal file
@ -0,0 +1,37 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/log/supervisor
|
||||
|
||||
# Enable communication to supervised processes
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[program:backend-flo]
|
||||
command=/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid
|
||||
directory=/opt/coins/nodes/flo
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
stdout_logfile=/var/log/supervisor/backend-flo.out.log
|
||||
stderr_logfile=/var/log/supervisor/backend-flo.err.log
|
||||
|
||||
[program:blockbook-flo]
|
||||
command=/opt/coins/blockbook/flo/bin/blockbook -blockchaincfg=/opt/coins/blockbook/flo/config/blockchaincfg.json -datadir=/opt/coins/data/flo/blockbook/db -sync -internal=:9066 -public=:9166 -certfile=/opt/coins/blockbook/flo/cert/blockbook -explorer= -log_dir=/opt/coins/blockbook/flo/logs -dbcache=1073741824
|
||||
directory=/opt/coins/blockbook/flo
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
stdout_logfile=/var/log/supervisor/blockbook-flo.out.log
|
||||
stderr_logfile=/var/log/supervisor/blockbook-flo.err.log
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
BIN
deb-files-testnet/backend-flo-testnet_0.15.1.1-satoshilabs-1_amd64.deb
Executable file
BIN
deb-files-testnet/backend-flo-testnet_0.15.1.1-satoshilabs-1_amd64.deb
Executable file
Binary file not shown.
BIN
deb-files-testnet/blockbook-flo-testnet_0.4.0_amd64.deb
Executable file
BIN
deb-files-testnet/blockbook-flo-testnet_0.4.0_amd64.deb
Executable file
Binary file not shown.
BIN
deb-files-testnet/peers.dat
Normal file
BIN
deb-files-testnet/peers.dat
Normal file
Binary file not shown.
37
deb-files-testnet/supervisord.conf
Normal file
37
deb-files-testnet/supervisord.conf
Normal file
@ -0,0 +1,37 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
childlogdir=/var/log/supervisor
|
||||
|
||||
# Enable communication to supervised processes
|
||||
[unix_http_server]
|
||||
file=/var/run/supervisor.sock
|
||||
chmod=0700
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///var/run/supervisor.sock
|
||||
|
||||
[program:backend-flo-testnet]
|
||||
command=/opt/coins/nodes/flo_testnet/bin/flod --testnet -datadir=/opt/coins/data/flo_testnet/backend -conf=/opt/coins/nodes/flo_testnet/flo_testnet.conf -pid=/run/flo_testnet/flo_testnet.pid
|
||||
directory=/opt/coins/nodes/flo_testnet
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
stdout_logfile=/var/log/supervisor/backend-flo-testnet.log
|
||||
stderr_logfile=/var/log/supervisor/backend-flo-testnet.err
|
||||
|
||||
[program:blockbook-flo-testnet]
|
||||
command=/opt/coins/blockbook/flo_testnet/bin/blockbook -blockchaincfg=/opt/coins/blockbook/flo_testnet/config/blockchaincfg.json -datadir=/opt/coins/data/flo_testnet/blockbook/db -sync -internal=:19066 -public=:19166 -certfile=/opt/coins/blockbook/flo_testnet/cert/blockbook -explorer= -log_dir=/opt/coins/blockbook/flo_testnet/logs -dbcache=1073741824
|
||||
directory=/opt/coins/blockbook/flo_testnet
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=10
|
||||
stdout_logfile=/var/log/supervisor/blockbook-flo-testnet.log
|
||||
stderr_logfile=/var/log/supervisor/blockbook-flo-testnet.err
|
||||
|
||||
[include]
|
||||
files = /etc/supervisor/conf.d/*.conf
|
||||
@ -1,45 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
blockbook-backend:
|
||||
image: ${BACKEND_IMAGE}
|
||||
container_name: ${BACKEND_CONTAINER_NAME}
|
||||
networks:
|
||||
- blockbook
|
||||
volumes:
|
||||
- blockbook:/opt
|
||||
- ${BACKEND_BOOTSTRAP_FILE:-/dev/null}:/local-bootstrap/bootstrap-blockbook-flo-mainnet-backend.tar.gz # Use /dev/null if no file
|
||||
ports:
|
||||
- "${BACKEND_PORT_1}:38366"
|
||||
- "${BACKEND_PORT_2}:8066"
|
||||
command: backend
|
||||
environment:
|
||||
- BOOTSTRAP_FILE=/local-bootstrap/bootstrap-blockbook-flo-mainnet-backend.tar.gz # Set to empty string if not provided
|
||||
- BOOTSTRAP_URL=${BACKEND_BOOTSTRAP_URL:-} # Set to empty string if not provided
|
||||
|
||||
blockbook-frontend:
|
||||
image: ${FRONTEND_IMAGE}
|
||||
container_name: ${FRONTEND_CONTAINER_NAME}
|
||||
networks:
|
||||
- blockbook
|
||||
volumes:
|
||||
- blockbook:/opt
|
||||
- ${FRONTEND_BOOTSTRAP_FILE:-/dev/null}:/local-bootstrap/bootstrap-blockbook-flo-mainnet-frontend.tar.gz # Use /dev/null if no file
|
||||
ports:
|
||||
- "${FRONTEND_PORT_1}:9166"
|
||||
- "${FRONTEND_PORT_2}:9066"
|
||||
depends_on:
|
||||
- blockbook-backend
|
||||
entrypoint: /bin/sh -c
|
||||
command: >
|
||||
"/opt/entrypoint.sh frontend $(getent hosts blockbook-backend | awk '{ print $1 }')"
|
||||
environment:
|
||||
- BOOTSTRAP_FILE=/local-bootstrap/bootstrap-blockbook-flo-mainnet-frontend.tar.gz # Set to empty string if not provided
|
||||
- BOOTSTRAP_URL=${FRONTEND_BOOTSTRAP_URL:-} # Set to empty string if not provided
|
||||
|
||||
volumes:
|
||||
blockbook:
|
||||
|
||||
networks:
|
||||
blockbook:
|
||||
driver: bridge
|
||||
131
entrypoint.sh
131
entrypoint.sh
@ -1,131 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Paths for frontend bootstrap files
|
||||
FRONTEND_BOOTSTRAP_URL_FILE="/opt/coins/data/flo/blockbook/bootstrap-url.txt"
|
||||
FRONTEND_BOOTSTRAP_FILE_HASH_FILE="/opt/coins/data/flo/blockbook/bootstrap-file-hash.txt"
|
||||
|
||||
# Paths for backend bootstrap files
|
||||
BACKEND_BOOTSTRAP_URL_FILE="/opt/coins/data/flo/backend/bootstrap-url.txt"
|
||||
BACKEND_BOOTSTRAP_FILE_HASH_FILE="/opt/coins/data/flo/backend/bootstrap-file-hash.txt"
|
||||
|
||||
# Function to calculate the hash of a file
|
||||
calculate_file_hash() {
|
||||
local file=$1
|
||||
sha256sum "$file" | awk '{print $1}'
|
||||
}
|
||||
|
||||
# Function to update config file
|
||||
update_config_file() {
|
||||
local config_path=$1
|
||||
local new_ip=$2
|
||||
if [ -n "$new_ip" ]; then
|
||||
echo "Updating config file: $config_path with IP: $new_ip"
|
||||
if ! sed -i "s/127.0.0.1/$new_ip/g" "$config_path"; then
|
||||
echo "Failed to update config file: $config_path"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to handle bootstrap from URL
|
||||
handle_bootstrap_url() {
|
||||
local bootstrap_url=$1
|
||||
local destination_dir=$2
|
||||
local url_file=$3
|
||||
local bootstrap_file=$4
|
||||
|
||||
if [ -z "$bootstrap_url" ]; then
|
||||
echo "No bootstrap URL provided, skipping download."
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -f "$url_file" ]; then
|
||||
local existing_url
|
||||
existing_url=$(cat "$url_file")
|
||||
if [ "$existing_url" = "$bootstrap_url" ]; then
|
||||
echo "Bootstrap URL already processed, skipping download and extraction."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Downloading bootstrap file from: $bootstrap_url"
|
||||
curl -L -o "/tmp/$bootstrap_file" "$bootstrap_url"
|
||||
echo "Cleaning and extracting bootstrap file to: $destination_dir"
|
||||
mkdir -p "$destination_dir"
|
||||
rm -rf "$destination_dir"/*
|
||||
tar -xzvf "/tmp/$bootstrap_file" -C "$destination_dir"
|
||||
rm "/tmp/$bootstrap_file"
|
||||
|
||||
echo "$bootstrap_url" > "$url_file"
|
||||
}
|
||||
|
||||
# Function to handle bootstrap from file
|
||||
handle_bootstrap_file() {
|
||||
local bootstrap_file=$1
|
||||
local destination_dir=$2
|
||||
local hash_file=$3
|
||||
|
||||
if [ -z "$bootstrap_file" ] || [ ! -f "$bootstrap_file" ]; then
|
||||
echo "No valid bootstrap file provided, skipping extraction."
|
||||
return
|
||||
fi
|
||||
|
||||
local new_hash
|
||||
new_hash=$(calculate_file_hash "$bootstrap_file")
|
||||
|
||||
if [ -f "$hash_file" ]; then
|
||||
local existing_hash
|
||||
existing_hash=$(cat "$hash_file")
|
||||
if [ "$existing_hash" = "$new_hash" ]; then
|
||||
echo "Bootstrap file already processed, skipping extraction."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using bootstrap file: $bootstrap_file"
|
||||
echo "Cleaning and extracting bootstrap file to: $destination_dir"
|
||||
mkdir -p "$destination_dir"
|
||||
rm -rf "$destination_dir"/*
|
||||
tar -xzf "$bootstrap_file" -C "$destination_dir"
|
||||
|
||||
echo "$new_hash" > "$hash_file"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"frontend")
|
||||
if [ -z "$2" ]; then
|
||||
echo "Missing parameter: new_ip for frontend"
|
||||
exit 1
|
||||
fi
|
||||
new_ip=$2
|
||||
echo "Running frontend command with IP: $new_ip"
|
||||
|
||||
if [ -n "$BOOTSTRAP_FILE" ] && [ -f "$BOOTSTRAP_FILE" ]; then
|
||||
handle_bootstrap_file "$BOOTSTRAP_FILE" "/opt/coins/data/flo/blockbook" "$FRONTEND_BOOTSTRAP_FILE_HASH_FILE"
|
||||
elif [ -n "$BOOTSTRAP_URL" ]; then
|
||||
handle_bootstrap_url "$BOOTSTRAP_URL" "/opt/coins/data/flo/blockbook" "$FRONTEND_BOOTSTRAP_URL_FILE" "bootstrap-frontend.tar.gz"
|
||||
fi
|
||||
|
||||
update_config_file "/opt/coins/blockbook/flo/config/blockchaincfg.json" "$new_ip"
|
||||
cd /opt/coins/blockbook/flo
|
||||
exec /opt/coins/blockbook/flo/bin/blockbook -blockchaincfg=/opt/coins/blockbook/flo/config/blockchaincfg.json -datadir=/opt/coins/data/flo/blockbook/db -sync -internal=:9066 -public=:9166 -certfile=/opt/coins/blockbook/flo/cert/blockbook -explorer= -log_dir=/opt/coins/blockbook/flo/logs -dbcache=1073741824
|
||||
;;
|
||||
"backend")
|
||||
echo "Running backend command"
|
||||
|
||||
if [ -n "$BOOTSTRAP_FILE" ] && [ -f "$BOOTSTRAP_FILE" ]; then
|
||||
handle_bootstrap_file "$BOOTSTRAP_FILE" "/opt/coins/data/flo/backend" "$BACKEND_BOOTSTRAP_FILE_HASH_FILE"
|
||||
elif [ -n "$BOOTSTRAP_URL" ]; then
|
||||
handle_bootstrap_url "$BOOTSTRAP_URL" "/opt/coins/data/flo/backend" "$BACKEND_BOOTSTRAP_URL_FILE" "bootstrap-backend.tar.gz"
|
||||
fi
|
||||
|
||||
cd /opt/coins/nodes/flo
|
||||
exec /opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: $1"
|
||||
echo "Usage: $0 {frontend new_ip|backend}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
47
start.sh
Normal file
47
start.sh
Normal file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOWNLOAD_DIR="/tmp"
|
||||
EXTRACT_DIR="/opt/coins"
|
||||
ZIP_FILE="${DOWNLOAD_DIR}/data.tar.gz"
|
||||
SUPERVISOR_CONF="/etc/supervisor/supervisord.conf"
|
||||
|
||||
mkdir -p ${DOWNLOAD_DIR}
|
||||
|
||||
start_supervisor() {
|
||||
echo "Starting Supervisor..."
|
||||
/usr/bin/supervisord -c ${SUPERVISOR_CONF}
|
||||
}
|
||||
#setting the zip url to mainnet or testnet (bootstrap)
|
||||
if [ "${NETWORK}" = "testnet" ]; then
|
||||
ZIP_URL="${TESTNET_ZIP_URL}"
|
||||
elif [ "${NETWORK}" = "mainnet" ]; then
|
||||
ZIP_URL="${MAINNET_ZIP_URL}"
|
||||
else
|
||||
echo "Invalid or missing NETWORK variable. Please set NETWORK to 'testnet' or 'mainnet'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#to download bootstrap or not.
|
||||
if [ "${ZIP}" = "true" ]; then
|
||||
echo "Downloading ${ZIP_URL}..."
|
||||
wget -q --show-progress ${ZIP_URL} -O ${ZIP_FILE}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to download the zip file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Extracting ${ZIP_FILE} to ${EXTRACT_DIR}..."
|
||||
tar -xzf ${ZIP_FILE} -C ${EXTRACT_DIR}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to extract the zip file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm ${ZIP_FILE}
|
||||
else
|
||||
echo "Skipping download and extraction of the zip file."
|
||||
fi
|
||||
|
||||
start_supervisor
|
||||
Loading…
Reference in New Issue
Block a user