Compare commits

..

25 Commits

Author SHA1 Message Date
Vivek Teega
3d336572be
Merge pull request #5 from sahaj05/Dockerbook
basic testnet changes
2023-09-29 17:12:25 +05:30
Kumar Sahaj
84574b507a new changees 2023-09-29 11:39:02 +00:00
Kumar Sahaj
a684783e85 Merge branch 'Dockerbook' of https://github.com/sahaj05/blockbook-docker into Dockerbook 2023-09-29 11:33:20 +00:00
Kumar Sahaj
2110bb5e16 dockerfile for testnet 2023-09-29 11:32:59 +00:00
Vivek Teega
00efd27bce
Merge pull request #4 from sahaj05/Dockerbook
Pulling changes made by Sahaj
2023-09-27 23:22:51 +05:30
Kumar Sahaj
398b08fc00 added testnet_files 2023-09-27 10:00:42 +00:00
Kumar Sahaj
a9f569655c updated 2023-09-21 11:12:05 +00:00
Kumar Sahaj
a03742524c updated documentation 2023-09-21 10:08:12 +00:00
Kumar Sahaj
d8be353192 removed dockerfile 2023-09-21 09:27:42 +00:00
Kumar Sahaj
31c346aa3e updated docker files for test_net and main_net 2023-09-21 09:06:35 +00:00
Kumar Sahaj
60150aa8e4 test_net dockerfile 2023-09-21 08:58:34 +00:00
Kumar Sahaj
1024f11c83 video support added 2023-09-21 08:02:48 +00:00
Kumar Sahaj
af189d23fd asdf 2023-09-21 07:31:53 +00:00
Kumar Sahaj
c6f85bca91 checks_1 2023-09-21 07:30:58 +00:00
Kumar Sahaj
d35075f35f news 2023-09-21 04:34:06 +00:00
Kumar Sahaj
1ac3bcb9b1 new _changes 2023-09-21 04:31:52 +00:00
Kumar Sahaj
b3f34bdc0e checksss 2023-09-20 14:49:15 +00:00
Kumar Sahaj
2833fcea47 checkss 2023-09-20 14:46:07 +00:00
Kumar Sahaj
8fd3f5875e checks1 2023-09-20 14:43:51 +00:00
Kumar Sahaj
59f423e8da checks 2023-09-20 14:38:58 +00:00
Kumar Sahaj
efbce1e9df check 2023-09-20 14:01:54 +00:00
Kumar Sahaj
8bda098621 Step guide for dockerising blockbook 2023-09-20 13:57:14 +00:00
sahaj05
f1fcec6a28
Merge branch 'ranchimall:main' into main 2023-09-20 15:33:31 +05:30
sahaj05
45a58f28b4
Create Blockbook-flo.service Content
Contains the starting command for Blockbook-flo.service
2023-09-18 12:53:13 +05:30
sahaj05
36c8cee4d2
Create Backend-flo.service Content
Contains the starting command for backend-flo.service
2023-09-18 12:49:21 +05:30
26 changed files with 552 additions and 269 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -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

View File

@ -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

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
.env
playbook.yml

View File

@ -0,0 +1,42 @@
[Unit]
Description=Flo backend daemon
After=network.target
[Service]
ExecStart=/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid
User=flo
Restart=on-failure
TimeoutStopSec=300
WorkingDirectory=/opt/coins/nodes/flo
Type=forking
RuntimeDirectory=flo
PIDFile=/run/flo/flo.pid
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,38 @@
[Unit]
Description=Blockbook daemon (Flo)
After=network.target
Wants=backend-flo.service
[Service]
ExecStart=/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
User=blockbook-flo
Type=simple
Restart=on-failure
TimeoutStopSec=300
WorkingDirectory=/opt/coins/blockbook/flo
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -1,21 +1,52 @@
FROM ubuntu:22.04
# Use a base image
FROM cruizba/ubuntu-dind:latest
# 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
# Install necessary packages
RUN apt-get update && \
apt-get install -y wget gnupg2 software-properties-common supervisor make git sudo
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
# Mount the Docker socket from the host into the container
# VOLUME /var/run/docker.sock:/var/run/docker.sock
WORKDIR /opt/coins/blockbook/flo
# Build app (You can add your application build steps here)
RUN git clone https://github.com/ranchimall/blockbook
# WORKDIR /blockbook
# RUN sudo make all-flo
# Execution
COPY ./entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh
ENTRYPOINT ["/opt/entrypoint.sh"]
# Install deb files
# RUN sudo apt install -y ./build/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && \
# sudo apt install -y ./build/blockbook-flo_0.4.0_amd64.deb
# Download deb files
# RUN wget https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb \
# https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/blockbook-flo_0.4.0_amd64.deb
# Create run flo directory
# RUN mkdir -p /run/flo
# # Create a common group (e.g., flo-group) and set permissions
# RUN groupadd flo-group && \
# usermod -aG flo-group flo && \
# usermod -aG flo-group blockbook-flo && \
# chown :flo-group /run/flo && \
# chmod 777 /run/flo
# Setting up supervisor configurations (Uncomment and add your configuration files)
COPY alt-helper.sh /
# COPY blockbook-flo.conf /etc/supervisor/conf.d/
# COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create log files
# RUN touch /var/log/backend-flo-error.log && \
# touch /var/log/backend-flo.log && \
# touch /var/log/blockbook-flo-error.log && \
# touch /var/log/blockbook-flo.log
# Expose ports
EXPOSE 22 80 9166
# Start supervisord (Uncomment this line)
# CMD ["/usr/bin/supervisord"]
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/usr/bin/bash", "/alt-helper.sh"]

View File

@ -0,0 +1,52 @@
# Use a base image
FROM cruizba/ubuntu-dind:latest
# Install necessary packages
RUN apt-get update && \
apt-get install -y wget gnupg2 software-properties-common supervisor make git sudo
# Mount the Docker socket from the host into the container
# VOLUME /var/run/docker.sock:/var/run/docker.sock
# Build app (You can add your application build steps here)
RUN git clone https://github.com/ranchimall/blockbook
# WORKDIR /blockbook
# RUN sudo make all-flo
# Install deb files
# RUN sudo apt install -y ./build/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && \
# sudo apt install -y ./build/blockbook-flo_0.4.0_amd64.deb
# Download deb files
# RUN wget https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb \
# https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/blockbook-flo_0.4.0_amd64.deb
# Create run flo directory
# RUN mkdir -p /run/flo
# # Create a common group (e.g., flo-group) and set permissions
# RUN groupadd flo-group && \
# usermod -aG flo-group flo && \
# usermod -aG flo-group blockbook-flo && \
# chown :flo-group /run/flo && \
# chmod 777 /run/flo
# Setting up supervisor configurations (Uncomment and add your configuration files)
COPY alt-helper.sh /
# COPY blockbook-flo.conf /etc/supervisor/conf.d/
# COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create log files
# RUN touch /var/log/backend-flo-error.log && \
# touch /var/log/backend-flo.log && \
# touch /var/log/blockbook-flo-error.log && \
# touch /var/log/blockbook-flo.log
# Expose ports
EXPOSE 22 80 9166
# Start supervisord (Uncomment this line)
# CMD ["/usr/bin/supervisord"]
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/usr/bin/bash", "/alt-helper.sh"]

55
Dockerfile-prebuilt Normal file
View File

@ -0,0 +1,55 @@
# syntax=docker/dockerfile:1.3-labs
# Use a base image
FROM cruizba/ubuntu-dind:focal-24.0.6
# Install necessary packages
RUN apt update && \
apt install -y wget gnupg2 software-properties-common supervisor sudo unzip
# Mount the Docker socket from the host into the container
# VOLUME /var/run/docker.sock:/var/run/docker.sock
# # Build app (You can add your application build steps here)
# RUN git clone https://github.com/ranchimall/blockbook
# WORKDIR /blockbook
# RUN --security=insecure cd /blockbook && make all-flo
# # Install deb files
# RUN sudo apt install -y ./build/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && \
# sudo apt install -y ./build/blockbook-flo_0.4.0_amd64.deb
# Download deb files
RUN wget https://github.com/ranchimall/blockbook-docker/archive/main.zip && unzip main.zip
RUN cd blockbook-docker-main && sudo apt install -y ./dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && sudo apt install -y ./dind_blockbook-flo_0.4.0_amd64.deb
# Create run flo directory
RUN mkdir -p /run/flo
# # Create a common group (e.g., flo-group) and set permissions
RUN groupadd flo-group && \
usermod -aG flo-group flo && \
usermod -aG flo-group blockbook-flo && \
chown :flo-group /run/flo && \
chmod 777 /run/flo
# Setting up supervisor configurations (Uncomment and add your configuration files)
# COPY alt-helper.sh /
# COPY blockbook-flo.conf /etc/supervisor/conf.d/
# COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create log files
# RUN touch /var/log/backend-flo-error.log && \
# touch /var/log/backend-flo.log && \
# touch /var/log/blockbook-flo-error.log && \
# touch /var/log/blockbook-flo.log
COPY prebuilt-helper.sh /
# Expose ports
EXPOSE 22 80 9166
# Start supervisord (Uncomment this line)
# CMD ["/usr/bin/supervisord"]
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/usr/bin/bash", "/prebuilt-helper.sh"]

16
Main_net_Dockerfile Normal file
View File

@ -0,0 +1,16 @@
# Use a base image
FROM nestybox/ubuntu-focal-systemd-docker
# Install necessary packages
RUN apt update && \
apt install -y wget gnupg2 software-properties-common unzip
# Download deb files
RUN wget https://github.com/ranchimall/blockbook-docker/archive/main.zip && unzip main.zip
RUN cd blockbook-docker-main && sudo apt install -y ./dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && sudo apt install -y ./dind_blockbook-flo_0.4.0_amd64.deb
# Expose ports
EXPOSE 22 80 9166
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/lib/systemd/systemd"]

181
README.md
View File

@ -1,48 +1,177 @@
# Blockbook docker
## Roadmap for upgrade
- [ ] 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.
## Video-Demonstration For Mainnet
+ https://drive.google.com/file/d/1MQlndJi1w992uhUtGTbf89uq0Q7mZR6k/view?usp=sharing (Only Text)
+ https://www.youtube.com/watch?v=QKd3EriMPx0 (Both Text And Audio)
## Quickstart
## Video-Demonstration For Testnet
+ https://youtu.be/EnX3-cBbpcE (Both Text And Audio)
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:
## Pre-requisites
Should have [sysbox installed on your machine](https://github.com/nestybox/sysbox/blob/master/docs/developers-guide/build.md)
## Main commands (For Both Mainnet and Testnet)
```
sudo docker-compose up -d
sudo docker run -d --runtime=sysbox-runc -P -p <hostport>:9166 --name blockbook ranchimallfze/blockbook:1.0.0
```
## Running blockbook manually
## Requirements
### Installation of Sysbox:
```
git clone --recursive https://github.com/nestybox/sysbox.git
make (For this step go to the sysbox directory)
make sysbox-static
sudo make install
make sysbox TARGET_ARCH=arm64
sudo ./docker-cfg --sysbox-runtime=enable (For this step go to the scr directory)
<!--If in step 6 command not found error comes then first install jq and then again run this command.-->
```
### For Uninstalling:
```
sudo make uninstall
make clean
```
### Installation of Docker:
```
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/
docker-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/
ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
<!--Replace focal with your Ubuntu version (e.g., bionic, xenial, or hirsute) if you are using a different version-->
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker
sudo docker --version
<!--If installed correctly the version will be displayed-->
```
docker volume create blockbook
## How to see available ports ?
docker network create blockbook
+ Open a new terminal on your Ubuntu system and copy the code given below:
```
# 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
# Specify the range of ports you want to check (e.g., 8000 to 9000)
start_port=8000
end_port=9000
# 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
# Use a loop to check each port in the specified range
for port in $(seq "$start_port" "$end_port"); do
# Use netstat or ss to check if the port is in use
if ! ss -tuln | grep -q ":$port\b"; then
echo "Port $port is available"
fi
done
# 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
```
# 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
# 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
## Running Manually For Both Mainnet And Testnet
# 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
+ After the installation of docker and sysbox run the dockerfile.
For running first we build its docker-image by the following command:
```
docker build -t <IMG_NAME> .
<!--If the directory of the dockerfile and the present directory is same-->
docker build -f <PATH_TO_DOCKERFILE> -t <IMG_NAME> <DOCKERFILE DIRECTORY>
<!--If the directory of the dockerfile and the present directory is not same-->
```
+ After building the docker-image use the following command to run it.
```
docker run -d --privileged -p <HOST_PORT>:<CONTAINER_PORT> --name <CONTAINER_NAME> <IMG_NAME>
<!--The container port for our docker file is 9166.-->
docker run -d --privileged -p <HOST_PORT>:9166 --name <CONTAINER_NAME> <IMG_NAME>
```
+ Now access the blockbook by opening the following LINK: https://localhost:<HOST_PORT>/
Use xdg-open https://localhost:<HOST_PORT>/ to open the link through the terminal and can view the interface of Blockbook.
## Testing
The code and steps required to run Docker version of Blockbook block explorer
```
sudo docker build -t blockbook-althelper -f Dockerfile-althelper .
sudo docker run -d --privileged -p 9166:9166 d5e56e218acd
```
```
docker buildx create --driver-opt image=moby/buildkit:master --use --name insecure-builder --buildkitd-flags '--allow-insecure-entitlement security.insecure'
docker buildx use insecure-builder
docker buildx build --allow security.insecure ...(other build args)...
sudo docker buildx build --allow security.insecure -t blockbook .
docker buildx rm insecure-builder
sudo docker run -v /var/run/docker.sock:/var/run/docker.sock -ti ubuntu:20.04
```
```
sudo docker run -d --runtime=sysbox-runc -P -p 9167:9166 5018bee64419
sudo docker run -d --runtime=sysbox-runc --net=host -P 5018bee64419
```
## Code Explanation For Mainnet
+ We use the base image "nestybox/ubuntu-focal-systemd-docker," which is an Ubuntu-based image with
systemd for managing system services.
+ We update the package list and installs necessary packages like wget, gnupg2,software-properties-common,
and unzip.
+ The Dockerfile downloads a ZIP archive containing Debian (.deb) files from a GitHub repository and
extracts them.
+ Within the extracted directory, it installs two Debian packages ("dind_backend-flo_0.15.1.1-satoshilabs
-1_amd64.deb" and "dind_blockbook-flo_0.4.0_amd64.deb") using apt .
+ It exposes three ports (22, 80, and 9166) for potential network access.
+ The CMD instruction specifies the default command to run when a container is started based on this
image. In this case, it starts the systemd initialization process.
## Code Explanation For Testnet
+ This line specifies the base image for the Docker container. It starts with a base image called nestybox/ubuntu-focal-systemd-docker,
which includes Ubuntu Focal Fossa (20.04) with systemd support.
+ We run a shell command inside the container during the image-building process. It updates the package list by executing apt
update. The && operator is used to chain multiple commands in a single line.
+ We define an argument named TESTNET with a default value of false. Docker ARGs can be used to pass values at build time, and
in this case, it's determining whether to set up the testnet or the mainnet environment.
+ Inside the if block, this line downloads a ZIP file containing testnet-related files from a GitHub repository using wget and
then unzips it using unzip.
+ If the value of TESTNET is not "true," the else block is executed.Inside the else block, similar to the if block, we download
a different ZIP file (likely containing mainnet-related files) and unzip it.
+ We change the working directory to the one where the mainnet ZIP file was extracted (blockbook-docker-main) and install the
same two Debian packages as in the if block.
+ Use of 'fi' marks the end of the conditional statement, closing the if-else block.
+ Now we expose the ports 22, 80, and 9166 and make them accessible for communication with the host system or other containers.
+ The CMD instruction specifies the default command to run when a container is started based on this
image. In this case, it starts the systemd initialization process.
## Why Sysbox Is Used ?
+ When you run Docker containers inside a Docker container (DinD), the inner containers typically share
the same Docker daemon as the host and other containers. This can lead to security and isolation concerns.
+ Sysbox allows you to run containers within an isolated environment, providing stronger separation
between inner containers, the host, and other outer containers. This is achieved by creating separate container runtimes for each inner container using runc (the OCI runtime).
+ In our dockerfile we are able to execute systemctl command by using sysbox.

24
Test_net_Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# Use a base image
FROM nestybox/ubuntu-focal-systemd-docker
# Install necessary packages
RUN apt update && \
apt install -y wget gnupg2 software-properties-common unzip
# Download deb files based on the TESTNET environment variable
ARG TESTNET=false
# If TESTNET is true, download testnet deb files; otherwise, download mainnet deb files
RUN if [ "$TESTNET" = "true" ]; then \
wget https://github.com/ranchimall/blockbook-docker/archive/testnet.zip && unzip testnet.zip && \
cd blockbook-docker-testnet && sudo apt install -y ./dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && sudo apt install -y ./dind_blockbook-flo_0.4.0_amd64.deb; \
else \
wget https://github.com/ranchimall/blockbook-docker/archive/main.zip && unzip main.zip && \
cd blockbook-docker-main && sudo apt install -y ./dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && sudo apt install -y ./dind_blockbook-flo_0.4.0_amd64.deb; \
fi
# Expose ports
EXPOSE 22 80 9166
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/lib/systemd/systemd"]

23
Testnet_Dockerfile Normal file
View File

@ -0,0 +1,23 @@
# Use a base image
FROM nestybox/ubuntu-focal-systemd-docker
# Install necessary packages
RUN apt update && \
apt install -y wget gnupg2 software-properties-common unzip
# Download and unzip the source code
RUN wget https://github.com/ranchimall/blockbook-docker/archive/main.zip && \
unzip main.zip && \
rm main.zip
# Change working directory to the unzipped source code directory
WORKDIR /blockbook-docker-main
# Install the required Debian packages
RUN apt install -y ./deb-files/dind_backend-flo-testnet_0.15.1.1-satoshilabs-1_amd64.deb && \
apt install -y ./deb-files/dind_blockbook-flo-testnet_0.4.0_amd64.deb
# Expose ports
EXPOSE 22 80 19166
# Start your applications (Uncomment and replace with your application start commands)
CMD ["/lib/systemd/systemd"]

28
alt-helper.sh Normal file
View File

@ -0,0 +1,28 @@
cd /blockbook && sudo make all-flo
#1. Install deb files
cd /blockbook/build && sudo apt install -y ./backend-flo_0.15.1.1-satoshilabs-1_amd64.deb
cd /blockbook/build && sudo apt install -y ./blockbook-flo_0.4.0_amd64.deb
#2. create run flo dir
mkdir -p /run/flo
#3. create a group and add flo and blockbook-flo & set permission for dir
# Create a common group (e.g., flo-group)
groupadd flo-group
# Add users to the common group
usermod -aG flo-group flo
usermod -aG flo-group blockbook-flo
# Set the common group ownership on the directory
chown :flo-group /run/flo
# Give the group read-write permissions on the directory
chmod 777 /run/flo
# 4. run main commands as user
su -s /bin/bash -c "/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid" flo
su -s /bin/bash -c "cd /opt/coins/blockbook/flo && /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" blockbook-flo

8
backend-flo.conf Normal file
View File

@ -0,0 +1,8 @@
[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
user=flo
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/backend-flo.log
stderr_logfile=/var/log/backend-flo-error.log

1
blockbook Submodule

@ -0,0 +1 @@
Subproject commit a586ce22e64bb5beddb42d58b6499db024487148

8
blockbook-flo.conf Normal file
View File

@ -0,0 +1,8 @@
[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
user=root
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/blockbook-flo.log
stderr_logfile=/var/log/blockbook-flo-error.log

35
config-helper.sh Normal file
View File

@ -0,0 +1,35 @@
# Install make and git
apt install -y make git sudo
wget https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb
wget https://github.com/ranchimall/blockbook/releases/download/flo-v0.4.0-ubuntu/blockbook-flo_0.4.0_amd64.deb
#1. Install deb files
apt install sudo
sudo apt install -y /opt/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb
sudo apt install -y /opt/blockbook-flo_0.4.0_amd64.deb
#2. create run flo dir
mkdir -p /run/flo
#3. create a group and add flo and blockbook-flo & set permission for dir
# Create a common group (e.g., flo-group)
groupadd flo-group
# Add users to the common group
usermod -aG flo-group flo
usermod -aG flo-group blockbook-flo
# Set the common group ownership on the directory
chown :flo-group /run/flo
# Give the group read-write permissions on the directory
chmod 777 /run/flo
# 4. run main commands as user
# su -s /bin/bash -c "/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid" flo
# su -s /bin/bash -c "/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" blockbook-flo

Binary file not shown.

View File

@ -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

View File

@ -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

3
main-helper.sh Normal file
View File

@ -0,0 +1,3 @@
sudo systemctl start backend-flo.service
sudo systemctl start blockbook-flo.service

3
prebuilt-helper.sh Normal file
View File

@ -0,0 +1,3 @@
su -s /bin/bash -c "/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid" flo
su -s /bin/bash -c "cd /opt/coins/blockbook/flo && /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" blockbook-flo

13
supervisord.conf Normal file
View File

@ -0,0 +1,13 @@
[supervisord]
nodaemon=true
user=root
[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
user=flo
autostart=false
autorestart=false
redirect_stderr=true
stdout_logfile=/var/log/backend-flo.log
stderr_logfile=/var/log/backend-flo-error.log