zrpc-docker - Milestone 3 -> Docker Image Gerneration

Final version
	      includes : Option for starting  GUI
	                 Option for starting  RPC Server
                         Option for starting  expert mode
This commit is contained in:
Rene V. Vergara A. 2024-11-26 19:21:12 -05:00
parent f5f1eddc59
commit b142028c9f
31 changed files with 133 additions and 93 deletions

View file

@ -1,5 +1,5 @@
# ===================================================== # =====================================================
# Zenith RPC Server Image # Zenith Full Node Wallet and RPC Server
# ===================================================== # =====================================================
FROM ubuntu:22.04 FROM ubuntu:22.04
@ -9,9 +9,13 @@ RUN apt update
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
# Update the package list and install necessary packages # Update the package list and install necessary packages
RUN apt-get install -qqy xterm x11-apps
RUN apt-get install -y \ RUN apt-get install -y \
libxss-dev \
libxrandr-dev \
libsecp256k1-dev \ libsecp256k1-dev \
xclip \
libglew-dev \ libglew-dev \
libsdl2-dev libsdl2-dev
@ -19,7 +23,7 @@ RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Create a new user (e.g., "zenusr") and set a password # Create a new user (e.g., "zenusr") and set a password
RUN useradd -ms /bin/bash zenusr RUN useradd -ms /bin/bash zenusr
RUN echo "1234\n1234\n" | passwd zenusr RUN echo "1234\n1234\n" | passwd zenusr
RUN mkdir /home/zenusr/Zenith RUN mkdir /home/zenusr/Zenith
@ -29,8 +33,11 @@ COPY scripts/bash_rc_adm /root/.bashrc
COPY scripts/bash_rc_usr /home/zenusr/.bashrc COPY scripts/bash_rc_usr /home/zenusr/.bashrc
COPY scripts/welcome.sh /etc/profile.d/welcome.sh COPY scripts/welcome.sh /etc/profile.d/welcome.sh
RUN chmod +x /etc/profile.d/welcome.sh RUN chmod +x /etc/profile.d/welcome.sh
#
COPY bin/zenith /usr/local/bin
COPY bin/startzen /usr/local/bin
COPY bin/zenithserver /usr/local/bin COPY bin/zenithserver /usr/local/bin
COPY bin/startrpc /usr/local/bin #
COPY lib/librustzcash_wrapper.so /usr/local/lib COPY lib/librustzcash_wrapper.so /usr/local/lib
COPY Downloads/libc-bin_2.38-1ubuntu6_amd64.deb /home/zenusr/Downloads/ COPY Downloads/libc-bin_2.38-1ubuntu6_amd64.deb /home/zenusr/Downloads/
COPY Downloads/libc-dev-bin_2.38-1ubuntu6_amd64.deb /home/zenusr/Downloads/ COPY Downloads/libc-dev-bin_2.38-1ubuntu6_amd64.deb /home/zenusr/Downloads/
@ -45,4 +52,4 @@ USER zenusr
WORKDIR /home/zenusr WORKDIR /home/zenusr
ENV USER=zenusr ENV USER=zenusr
CMD ["startrpc"] CMD ["startzen"]

View file

@ -1,6 +0,0 @@
#!/bin/bash
if [ x"${EXPERT_MODE}" == "x" ]; then
zenithserver
else
/bin/bash -l
fi

9
docker_files/bin/startzen Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
if [ x"${EXPERT_MODE}" == "x0" ] && [ x"${RPC_SERVER}" == "x0" ]; then
zenith gui
elif [ x"${RPC_SERVER}" == "x1" ] && ( [ x"${EXPERT_MODE}" == "x0" ] || [ x"${EXPERT_MODE}" == "x1" ] ); then
zenithserver
else
# xterm -geometry 90x55 -fs 10 -fa DejaVuSansMono -cr green -bg black -fg lightgray
/bin/bash -l
fi

BIN
docker_files/bin/zenith Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

65
docker_files/cfg/runzenith Executable file
View file

@ -0,0 +1,65 @@
#!/bin/bash
ZFOLDER=~/Zenith
IMAGE_NAME=zenith-docker:0.7.0.0
EXPERTMODE="0"
RPCSERVER="0"
if [ $# -gt 0 ]; then
while [[ $# -gt 0 ]]; do
case $1 in
-e|--expert)
EXPERTMODE="1"
shift 2
break
;;
-r|--rpc)
RPCSERVER="1"
shift 2
break
;;
-h|--help)
echo
echo "======================================================"
echo "Zenith Full Node Wallet and RPC server "
echo "version 0.7.0.0"
echo "======================================================"
echo
echo "Usage: runzenith"
echo " runzenith -e|--expert"
echo " runzenith -r|--rpc"
echo "Decription"
echo " no params -> starts zenith GUI wallet"
echo " -e | --expert -> starts zenith in expert mode"
echo " -r | --rpc -> starts zenith's rpc server"
echo " -h | --help -> displays this screen"
echo
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
fi
# Check if data folder exists
if [ ! -d "$ZFOLDER" ]; then
echo "Error starting Zenith image"
echo "Zenith configurtion and data folder ($ZFOLDER) does not exists."
echo "Aborting process..."
exit
fi
# Check if the image exists locally
if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then
echo "Error starting Zenith image"
echo "Image $IMAGE_NAME not found locally."
echo "Aborting process..."
exit
fi
docker run --rm -it --mount src=$ZFOLDER,target=/home/zenusr/Zenith,type=bind --net=host --env DISPLAY=$DISPLAY --env EXPERT_MODE=$EXPERTMODE --env RPC_SERVER=$RPCSERVER $IMAGE_NAME
# End

View file

@ -1,43 +0,0 @@
#!/bin/bash
ZFOLDER=~/Zenith
IMAGE_NAME=zenithrpc-docker:0.7.0.0
for i in "$@"
do case $i in
-e=*|--expert=*)
EXPERTMODE="1"
;;
*)
EXPERTMODE="0"
;;
esac
done
# Check if docker engine is running
if ! systemctl is-active --quiet docker ; then
echo "Docker is not active/installed, "
echo "Please activate docker before proceeding!!."
echo "Aborting process..."
exit
fi
# Check if data folder exists
if [ ! -d "$ZFOLDER" ]; then
echo "Error starting Zenith RPC server image"
echo "Zenith configurtion and data folder ($ZFOLDER) does not exists."
echo "Aborting process..."
exit
fi
# Check if the image exists locally
if [[ "$(docker images -q $IMAGE_NAME 2> /dev/null)" == "" ]]; then
echo "Error starting Zenith RPC server image"
echo "Image $IMAGE_NAME not found locally."
echo "Aborting process..."
exit
fi
# Start image in detached mode
docker run --rm -d --mount src=$ZFOLDER,target=/home/zenusr/Zenith,type=bind --net=host --env EXPERT_MODE=$EXPERTMODE $IMAGE_NAME
# End

View file

@ -1,5 +1,6 @@
nodeUser = "user" nodeUser = "user"
nodePwd = "superSecret" nodePwd = "superSecret"
nodePort = 8234
dbFileName = "zenith.db" dbFileName = "zenith.db"
zebraHost = "127.0.0.1" zebraHost = "127.0.0.1"
zebraPort = 18232 zebraPort = 8232

View file

@ -4,14 +4,21 @@ echo "Docker image package generator"
echo echo
if ! systemctl is-active --quiet docker ; then if ! systemctl is-active --quiet docker ; then
echo "Docker is not active/installed, " echo "Docker is not active/installed, "
echo "Please activate docker before proceeding!!." echo "Please activate docker befor proceed!!."
echo echo
exit exit
fi fi
echo "Updating docker binary files ...." echo "Updating docker binary files ...."
echo echo
echo "... copying zenith server to ./bin folder" echo "... copying zenith to ./bin folder"
cp "../dist-newstyle/build/x86_64-linux/ghc-9.6.5/zenith-"$ZVERSION"/build/zenith/zenith" "bin/"
echo "... copying zenithserver to ./bin folder"
cp "../dist-newstyle/build/x86_64-linux/ghc-9.6.5/zenith-"$ZVERSION"/build/zenithserver/zenithserver" "bin/" cp "../dist-newstyle/build/x86_64-linux/ghc-9.6.5/zenith-"$ZVERSION"/build/zenithserver/zenithserver" "bin/"
echo "... copying assets folder to ./cfg folder"
if [ -d ./cfg/assets ]; then
rm -rf ./cfg/assets
fi
cp -r "../assets" "cfg/"
echo "... copying librustzcash_wrapper.so to ./lib folder" echo "... copying librustzcash_wrapper.so to ./lib folder"
cp "../zcash-haskell/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug/librustzcash_wrapper.so" "lib/" cp "../zcash-haskell/librustzcash-wrapper/target/x86_64-unknown-linux-gnu/debug/librustzcash_wrapper.so" "lib/"
echo echo
@ -19,36 +26,36 @@ echo
read -r -p "Do you want to create the docker image? [Y/n] " response read -r -p "Do you want to create the docker image? [Y/n] " response
case "$response" in case "$response" in
[yY]) [yY])
if docker image ls | grep -q "zenithrpc-docker" ; then if docker image ls | grep -q "zenith-docker" ; then
echo "... removing previous docker image" echo "... removing previous docker image"
docker rmi -f "zenithrpc-docker:"$ZVERSION docker rmi -f "zenith-docker:"$ZVERSION
fi fi
echo "... creating zenithrpc-docker:"$ZVERSION" image" echo "... creating zenith-docker:"$ZVERSION" image"
docker build -t "zenithrpc-docker:"$ZVERSION . docker build -t "zenith-docker:"$ZVERSION .
echo "... docker image zenithrpc-docker:"$ZVERSION" created." echo "... docker image zenith-docker:"$ZVERSION" created."
echo "... exporting zenithrpc-docker:"$ZVERSION" as .tar file" echo "... exporting zenith-docker:"$ZVERSION" as .tar file"
docker save -o zenithrpc-docker_$ZVERSION.tar zenithrpc-docker:$ZVERSION docker save -o zenith-docker_$ZVERSION.tar zenith-docker:$ZVERSION
echo "... zenithrpc-docker:"$ZVERSION" image ready." echo "... zenith-docker:"$ZVERSION" image ready."
echo "... creating distribution package file " echo "... creating distribution package file "
if [ -d zenithrpc-docker_$ZVERSION ]; then if [ -d zenith-docker_$ZVERSION ]; then
rm -rf zenithrpc-docker_$ZVERSION rm -rf zenith-docker_$ZVERSION
fi fi
echo "... creating distribution folder " echo "... creating distribution folder "
mkdir zenithrpc-docker_$ZVERSION mkdir zenith-docker_$ZVERSION
echo "... copying setup_docker script" echo "... copying setup_docker script"
chmod +x setup_docker chmod +x setup_docker
cp setup_docker zenithrpc-docker_$ZVERSION/ cp setup_docker zenith-docker_$ZVERSION/
chmod -x setup_docker chmod -x setup_docker
echo "... copying cfg folder" echo "... copying cfg folder"
cp -r cfg zenithrpc-docker_$ZVERSION/ cp -r cfg zenith-docker_$ZVERSION/
echo "... moving docker image to distribution folder" echo "... moving docker image to distribution folder"
mv zenithrpc-docker_$ZVERSION.tar zenithrpc-docker_$ZVERSION/ mv zenith-docker_$ZVERSION.tar zenith-docker_$ZVERSION/
if [ -f zenithrpc-docker_$ZVERSION.7z ]; then if [ -f zenith-docker_$ZVERSION.7z ]; then
rm zenithrpc-docker_$ZVERSION.7z rm zenith-docker_$ZVERSION.7z
fi fi
echo "... creating distribution package zenithrpc-docker_$ZVERSION.7z " echo "... creating distrigution package zenith-docker_$ZVERSION.7z "
7z a zenithrpc-docker_$ZVERSION.7z zenithrpc-docker_$ZVERSION 7z a zenith-docker_$ZVERSION.7z zenith-docker_$ZVERSION
echo "... distribution file created. (zenithrpc-docker_$ZVERSION.tar.gz)" echo "... distribution file created. (zenith-docker_$ZVERSION.tar.gz)"
;; ;;
*) *)
echo "... docker image not created." echo "... docker image not created."

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
echo echo
echo "=============================================" echo "============================================="
echo "Welcome to Zenith RPC seerver enviroment" echo "Welcome to Zenith Full Node Wallet enviroment"
echo "v0.7.0.0" echo "v0.7.0.0"
echo "Vergara Technologies LLC" echo "Expert mode"
echo "=============================================" echo "============================================="
echo echo

View file

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
ZVERSION="0.7.0.0" ZVERSION="0.7.0.0"
echo echo
echo "Zenith RPC Server Image Setup" echo "Zenith Full Node Wallet and RPC-Server Docker Image Setup"
echo echo
echo "... testing if docker service is active.." echo "... testing if docker service is active.."
if systemctl is-active --quiet docker; then if systemctl is-active --quiet docker; then
echo "... Docker service active" echo "... Docker service active"
echo echo
if [ -d $HOME"/Zenith" ]; then if [ -d $HOME"/Zenith" ]; then
echo "Warning: Zenith Server configuration already exist, this procedure will create" echo "Warning: Zenith configuration already exist, this procedure will create"
echo " a new configuration file. Your previous configurarion " echo " a new configuration file. Your previous configurarion "
echo " will be saved as 'previous-zenith.cfg'. (a Backup is recommended)." echo " will be saved as 'previous-zenith.cfg'. (a Backup is recommended)."
echo echo
@ -30,28 +30,28 @@ if systemctl is-active --quiet docker; then
echo "... creating Zenith folder" echo "... creating Zenith folder"
mkdir -p $HOME/Zenith/assets mkdir -p $HOME/Zenith/assets
fi fi
if docker image ls | grep -q "zenithrpc-docker" ; then if docker image ls | grep -q "zenith-docker" ; then
echo "... removing previous docker image" echo "... removing previous docker image"
docker rmi -f "zenithrpc-docker:"$ZVERSION docker rmi -f "zenith-docker:"$ZVERSION
fi fi
echo "... loading zenithrpc-docker:"$ZVERSION" image" echo "... loading zenith-docker:"$ZVERSION" image"
docker load < zenithrpc-docker_$ZVERSION.tar docker load < zenith-docker_$ZVERSION.tar
echo "... docker image zenithrpc-docker:"$ZVERSION" loaded." echo "... docker image zenith-docker:"$ZVERSION" loaded."
echo "... creating default configuration" echo "... creating default configuration"
cp cfg/zenith.cfg $HOME/Zenith/ cp cfg/zenith.cfg $HOME/Zenith/
echo "... copying zenith assets to Zenith folder." echo "... copying zenith assets to Zenith folder."
cp -r cfg/assets $HOME/Zenith/assets cp -r cfg/assets $HOME/Zenith
if ! [ -d $HOME/.local/bin ]; then if ! [ -d $HOME/.local/bin ]; then
echo "... creating $HOME/.local/bin folder" echo "... creating $HOME/.local/bin folder"
mkdir -p $HOME/.local/bin mkdir -p $HOME/.local/bin
else else
echo "... $HOME/.local/bin exists" echo "... $HOME/.local/bin exists"
fi fi
if [ -f $HOME/.local/bin/runzenithrpc ]; then if [ -f $HOME/.local/bin/runzenith ]; then
rm $HOME/.local/bin/runzenithrpc rm $HOME/.local/bin/runzenith
fi fi
echo "... copying runzenithrpc to $HOME/.local/bin" echo "... copying runzenith to $HOME/.local/bin"
cp cfg/runzenithrpc $HOME/.local/bin/ cp cfg/runzenith $HOME/.local/bin/
if ! echo $PATH | grep -q $HOME/.local/bin ; then if ! echo $PATH | grep -q $HOME/.local/bin ; then
echo PATH=$PATH:$HOME/.local/bin | tee -a $HOME/.bashrc echo PATH=$PATH:$HOME/.local/bin | tee -a $HOME/.bashrc
echo "... reloading configuration ...." echo "... reloading configuration ...."
@ -60,7 +60,7 @@ if systemctl is-active --quiet docker; then
echo "... PATH=$PATH" echo "... PATH=$PATH"
fi fi
echo echo
echo "To start Zenith RPC server execute 'runzenithrpc' from the command line." echo "To start zenith execute 'runzenith' from the command line."
else else
echo "... Docker service is not active" echo "... Docker service is not active"
echo "... Please activate Docker service first." echo "... Please activate Docker service first."

@ -1 +1 @@
Subproject commit 7965dc38c48da348f503a52ee10042fffc43f32c Subproject commit d45bd7dcf3c3cf4e893900a1774d24b14bf56591