Build single image, but separate execution

This commit is contained in:
Vivek Teega 2024-06-11 15:48:12 +05:30
parent 15b9955f98
commit a162ab19f3
3 changed files with 64 additions and 6 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM ubuntu:22.04
# Backend
COPY ./deb-files/backend-flo_0.15.1.1-satoshilabs-1_amd64.deb /opt/backend.deb
RUN apt update && apt install -y /opt/backend.deb
WORKDIR /opt/coins/nodes/flo
RUN sed -i 's/daemon=1/daemon=0/' /opt/coins/nodes/flo/flo.conf
# Frontend
COPY ./deb-files/blockbook-flo_0.4.0_amd64.deb /opt/blockbook.deb
RUN apt update && apt install -y /opt/blockbook.deb
WORKDIR /opt/coins/blockbook/flo
# Execution
COPY ./entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh
ENTRYPOINT ["/opt/entrypoint.sh"]

View File

@ -2,10 +2,31 @@
## Roadmap for upgrade
[X] - Create separate images for both backend and blockbook.
[X] - Attach the same volume to both the running containers of the images.
[ ] - Think of how Blockbook container will detect the spots of backend container
[ ] - 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.
- [ ] Think of how Blockbook container will detect the spots 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.
## Building and running blockbook image
```
docker build -f Dockerfile -t vivekteega/blockbook:1.0.0 .
docker volume create blockbook
# Run backend in "it" mode
docker run -it --mount source=blockbook,target=/opt -p 38366:38366 -p 8066:8066 vivekteega/blockbook:1.0.0 backend
# Run backend in daemon mode
docker run -d --mount source=blockbook,target=/ -p 38366:38366 -p 8066:8066 vivekteega/blockbook:1.0.0 backend
# Run frontend in "it" mode
docker run -it --mount source=blockbook,target=/opt -p 9166:9166 -p 9066:9066 vivekteega/blockbook:1.0.0 frontend
# Run frontend in it mode
docker run -d --mount source=blockbook,target=/ -p 9166:9166 -p 9066:9066 vivekteega/blockbook:1.0.0 frontend
```
## Building & running backend image
@ -28,5 +49,3 @@ docker run -it --mount source=blockbook,target=/opt/coins -p 9166:9166 -p 9066:9
docker run -d --mount source=blockbook,target=/opt/coins -p 9166:9166 -p 9066:9066 vivekteega/blockbook-frontend:1.0.0
```

20
entrypoint.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
case "$1" in
"frontend")
echo "Running frontend command"
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"
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|backend}"
exit 1
;;
esac