diff --git a/Dockerfile b/Dockerfile index cdb4d43..83057b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,16 @@ # Use a base image -FROM ubuntu:20.04 +FROM nestybox/ubuntu-focal-systemd-docker # Install necessary packages -RUN apt-get update && \ - apt-get install -y wget && \ - apt-get install -y gnupg2 && \ - apt-get install -y software-properties-common && \ - apt install supervisor +RUN apt update && \ + apt install -y wget gnupg2 software-properties-common unzip -# Download the pre-built files from GitHub releases -RUN 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 +# 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 -# Install the downloaded packages -RUN apt install -y ./backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && \ - apt install -y ./blockbook-flo_0.4.0_amd64.deb +# Expose ports +EXPOSE 22 80 9166 -# Clean up downloaded packages -RUN rm -f ./backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && \ - rm -f ./blockbook-flo_0.4.0_amd64.deb - -# Setting up supervisor configurations -#COPY backend-flo.conf /etc/supervisor/conf.d/ -#COPY blockbook-flo.conf /etc/supervisor/conf.d/ -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -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 -#RUN supervisorctl reread && supervisorctl update - -# Expose the port for the Blockbook web interface -EXPOSE 9166 - -# Start the Blockbook service -#CMD ["/usr/local/bin/blockbook", "--config", "/etc/blockbook/blockbook-flo.cfg"] -#CMD ["/opt/coins/nodes/flo/bin/flod -datadir=/opt/coins/data/flo/backend -conf=/opt/coins/nodes/flo/flo.conf -pid=/run/flo/flo.pid"] - -EXPOSE 22 80 -CMD ["/usr/bin/supervisord"] \ No newline at end of file +# Start your applications (Uncomment and replace with your application start commands) +CMD ["/lib/systemd/systemd"] \ No newline at end of file diff --git a/Dockerfile-althelper-cdbuild b/Dockerfile-althelper-cdbuild new file mode 100644 index 0000000..068d7d2 --- /dev/null +++ b/Dockerfile-althelper-cdbuild @@ -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"] \ No newline at end of file diff --git a/Dockerfile-prebuilt b/Dockerfile-prebuilt new file mode 100644 index 0000000..26ea3c1 --- /dev/null +++ b/Dockerfile-prebuilt @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index b80d9fa..1038f19 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,35 @@ # Blockbook docker +## Pre-requisites +Should have [sysbox installed on your machine](https://github.com/nestybox/sysbox/blob/master/docs/developers-guide/build.md) + +## Main commands +``` +sudo docker run -d --runtime=sysbox-runc -P -p :9166 --name blockbook ranchimallfze/blockbook:1.0.0 +``` + +## 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 +``` \ No newline at end of file diff --git a/alt-helper.sh b/alt-helper.sh new file mode 100644 index 0000000..99f8468 --- /dev/null +++ b/alt-helper.sh @@ -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 diff --git a/config-helper.sh b/config-helper.sh new file mode 100644 index 0000000..30580fa --- /dev/null +++ b/config-helper.sh @@ -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 \ No newline at end of file diff --git a/dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb b/dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb new file mode 100644 index 0000000..881497e Binary files /dev/null and b/dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb differ diff --git a/dind_blockbook-flo_0.4.0_amd64.deb b/dind_blockbook-flo_0.4.0_amd64.deb new file mode 100644 index 0000000..483afa4 Binary files /dev/null and b/dind_blockbook-flo_0.4.0_amd64.deb differ diff --git a/main-helper.sh b/main-helper.sh new file mode 100644 index 0000000..47b2965 --- /dev/null +++ b/main-helper.sh @@ -0,0 +1,3 @@ +sudo systemctl start backend-flo.service + +sudo systemctl start blockbook-flo.service \ No newline at end of file diff --git a/prebuilt-helper.sh b/prebuilt-helper.sh new file mode 100644 index 0000000..d4290a4 --- /dev/null +++ b/prebuilt-helper.sh @@ -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 \ No newline at end of file