Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging separate docker containers for backend and frontend code with main branch #16

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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
30 changes: 30 additions & 0 deletions .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Blockbook docker image | Build and Push
run-name: Building and pushing blockbook docker image to DockerHub
on: [push]

jobs:
build-push-blockbook-docker:
runs-on: self-hosted

steps:
- name: Checkout code
uses: actions/checkout@v4

- 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
13 changes: 13 additions & 0 deletions .github/workflows/learn-github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: learn-github-actions
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
check-bats-version:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g bats
- run: bats -v
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
playbook.yml
37 changes: 21 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# 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 ./deb-files/dind_backend-flo_0.15.1.1-satoshilabs-1_amd64.deb && sudo apt install -y ./deb-files/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"]
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

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

WORKDIR /opt/coins/blockbook/flo

# Execution
COPY ./entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh
ENTRYPOINT ["/opt/entrypoint.sh"]
52 changes: 0 additions & 52 deletions Dockerfile-althelper-cdbuild

This file was deleted.

55 changes: 0 additions & 55 deletions Dockerfile-prebuilt

This file was deleted.

16 changes: 0 additions & 16 deletions Dockerfile_testnet

This file was deleted.

55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
# Blockbook docker

## Pre-requisites
Should have [sysbox installed on your machine](https://github.com/nestybox/sysbox/blob/master/docs/developers-guide/build.md)
## Roadmap for upgrade

## Main commands
```
sudo docker run -d --runtime=sysbox-runc -P -p <hostport>:9166 --name blockbook ranchimallfze/blockbook:1.0.0
```
- [ ] 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.

## Testing
## Quickstart

The code and steps required to run Docker version of Blockbook block explorer
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:

```
sudo docker build -t blockbook-althelper -f Dockerfile-althelper .
sudo docker run -d --privileged -p 9166:9166 d5e56e218acd
sudo docker-compose up -d
```

## Running blockbook manually

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

docker volume create blockbook

sudo docker run -v /var/run/docker.sock:/var/run/docker.sock -ti ubuntu:20.04
```
docker network create blockbook

```
sudo docker run -d --runtime=sysbox-runc -P -p 9167:9166 5018bee64419
# 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

# 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

sudo docker run -d --runtime=sysbox-runc --net=host -P 5018bee64419
```
# 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

# 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

```
28 changes: 0 additions & 28 deletions alt-helper.sh

This file was deleted.

8 changes: 0 additions & 8 deletions backend-flo.conf

This file was deleted.

8 changes: 0 additions & 8 deletions blockbook-flo.conf

This file was deleted.

35 changes: 0 additions & 35 deletions config-helper.sh

This file was deleted.

Loading
Loading