Skip to content

Commit

Permalink
Fix local Docker build/start
Browse files Browse the repository at this point in the history
Signed-off-by: alexander.shenshin <alexander.shenshin@dsr-corporation.com>
  • Loading branch information
AlexanderShenshin committed Jan 18, 2023
1 parent 3e95ff8 commit 9217324
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 35 deletions.
6 changes: 4 additions & 2 deletions bin/von_generate_transactions
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

rm -rf /var/lib/indy/*

usage () {
Expand Down Expand Up @@ -68,9 +70,9 @@ if [ ! -z "$nodeNum" ]; then
#echo -e "================================================================================================"
fi

if [ ! -z $ipAddresses ]; then
if [ ! -z "$ipAddresses" ]; then
ipsArg="$ipAddresses"
elif [ ! -z $ipAddress ]; then
elif [ ! -z "$ipAddress" ]; then
ipsArg="$ipAddress","$ipAddress","$ipAddress","$ipAddress"
elif [ ! -z "$DOCKERHOST" ]; then
ipsArg="$DOCKERHOST","$DOCKERHOST","$DOCKERHOST","$DOCKERHOST"
Expand Down
41 changes: 20 additions & 21 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
- LOG_LEVEL=${LOG_LEVEL}
- RUST_LOG=${RUST_LOG}
- GENESIS_URL=${GENESIS_URL}
- ANONYMOUS=${ANONYMOUS}
- LEDGER_SEED=${LEDGER_SEED}
- LEDGER_CACHE_PATH=${LEDGER_CACHE_PATH}
- MAX_FETCH=${MAX_FETCH:-50000}
Expand All @@ -44,30 +43,30 @@ services:
ports:
- ${WEB_SERVER_HOST_PORT:-9000}:8000
volumes:
- ./config:/home/indy/config
- ./server:/home/indy/server
- ./config:/home/indy/config:ro
- ./server:/home/indy/server:ro

#
# Synchronization test
#
synctest:
image: von-network-base
command: ./scripts/start_synctest.sh
environment:
- IP=${IP}
- IPS=${IPS}
- DOCKERHOST=${DOCKERHOST}
- LOG_LEVEL=${LOG_LEVEL}
- RUST_LOG=${RUST_LOG}
networks:
- von
ports:
- ${WEB_SERVER_HOST_PORT:-9000}:8000
volumes:
- ./config:/home/indy/config
- ./server:/home/indy/server
- webserver-cli:/home/indy/.indy-cli
- webserver-ledger:/home/indy/ledger
# synctest:
# image: von-network-base
# command: ./scripts/start_synctest.sh
# environment:
# - IP=${IP}
# - IPS=${IPS}
# - DOCKERHOST=${DOCKERHOST}
# - LOG_LEVEL=${LOG_LEVEL}
# - RUST_LOG=${RUST_LOG}
# networks:
# - von
# ports:
# - ${WEB_SERVER_HOST_PORT:-9000}:8000
# volumes:
# - ./config:/home/indy/config
# - ./server:/home/indy/server
# - webserver-cli:/home/indy/.indy-cli
# - webserver-ledger:/home/indy/ledger

#
# Nodes
Expand Down
5 changes: 4 additions & 1 deletion docker/Dockerfile.node
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ ENV RUST_LOG ${RUST_LOG:-warning}


ADD --chown=indy:indy indy_config.py /etc/indy/
ADD --chown=indy:indy . $HOME

WORKDIR $HOME
ADD --chown=indy:indy bin bin
ADD --chown=indy:indy scripts scripts

RUN mkdir -p \
$HOME/cli-scripts \
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile.server
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM indy-vdr-test-python
FROM bcgovimages/von-image:node-1.12-6

ENV LOG_LEVEL ${LOG_LEVEL:-info}
ENV RUST_LOG ${RUST_LOG:-warning}

ADD server/requirements.txt server/
RUN pip3 install --no-cache-dir -r server/requirements.txt
RUN pip3 install -U pip && \
pip install --no-cache-dir -r server/requirements.txt

ADD --chown=indy:indy config ./config
ADD --chown=indy:indy server ./server
Expand Down
24 changes: 16 additions & 8 deletions manage
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ usage () {
taaUrl
- The URL to the raw content of the TAA in markdown format.
taaVersion
- The vesion of the TAA
- The version of the TAA
taaRatificationTime
- The date and time of TAA ratification by network government.
- On Linux and Windows (Git Bash):
Expand Down Expand Up @@ -182,7 +182,7 @@ usage () {
debugVolume <volume> [volumeMountFolder] - Mount a named volume into a 'debug' instance of the 'von-network-base' image with an interactive shell.
Provides a containerized environment to perform analysis on the ledger databases and files.
Starting with 'bcgovimages/von-image:node-1.12-4' the base image for von-network conatins the RocksDB sst_dump tool that can be used to verify
Starting with 'bcgovimages/von-image:node-1.12-4' the base image for von-network contains the RocksDB sst_dump tool that can be used to verify
and inspect the RocksDB database files; '*.sst' files.
For example the command 'find /debug_volume/ -name "*.sst" | xargs -I {} sst_dump --file={} --command=verify' can be used to do a quick
verification on all the database files once the container starts.
Expand Down Expand Up @@ -318,7 +318,7 @@ function initEnv() {
USE_SAMPLE_TAA=1
;;
*)
# If not recognized, save it for later procesing ...
# If not recognized, save it for later processing ...
set -- "$@" "$arg"
;;
esac
Expand All @@ -335,6 +335,8 @@ function initEnv() {
fi
export IP="$IP" IPS="$IPS"

export LEDGER_SEED=${LEDGER_SEED}

export LOG_LEVEL=${LOG_LEVEL:-info}
export RUST_LOG=${RUST_LOG:-warning}
}
Expand All @@ -350,7 +352,7 @@ function runCliCommand() {
displayCliUsage=1
;;
*)
# If not recognized, save it for later procesing ...
# If not recognized, save it for later processing ...
set -- "$@" "$arg"
;;
esac
Expand Down Expand Up @@ -727,7 +729,7 @@ function debugVolume()

backupVolumeMount=$(getVolumeMount ./${ROOT_BACKUP_DIR})/

echo -e "\nOpening a debug session with the followig volume mounts:\n - '${volume}':'${volumeMountFolder}'\n - '${backupVolumeMount}':'/${ROOT_BACKUP_DIR}'\n"
echo -e "\nOpening a debug session with the following volume mounts:\n - '${volume}':'${volumeMountFolder}'\n - '${backupVolumeMount}':'/${ROOT_BACKUP_DIR}'\n"
docker run \
--rm \
-it \
Expand Down Expand Up @@ -829,6 +831,13 @@ shift || COMMAND=usage
case "${COMMAND}" in
start|up)
initEnv "$@"
export LEDGER_SEED=${LEDGER_SEED:-000000000000000000000000Trustee1}
if [ ! -f config/genesis.txn ]; then
echo "Genesis transaction file not found, creating..."
docker run --rm -e "DOCKERHOST=${DOCKERHOST}" -e "IP=${IP}" -e "IPS=${IPS}" \
-v /$(pwd)/config:/home/indy/config \
von-network-base scripts/init_genesis.sh
fi
install_taa
${dockerCompose} \
up \
Expand All @@ -848,9 +857,6 @@ case "${COMMAND}" in
;;
start-web)
initEnv "$@"
if [ -z "$LEDGER_SEED" ]; then
export ANONYMOUS=1
fi
${dockerCompose} \
up \
-d webserver
Expand Down Expand Up @@ -886,9 +892,11 @@ case "${COMMAND}" in
remove_taa
;;
build)
docker-compose build webserver
docker build $(initDockerBuildArgs) -t von-network-base . -f docker/Dockerfile.node
;;
rebuild)
docker-compose build webserver
docker build $(initDockerBuildArgs) --no-cache --progress plain -t von-network-base . -f docker/Dockerfile.node
;;
dockerhost)
Expand Down
25 changes: 25 additions & 0 deletions scripts/init_genesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

if [ ! -d "/home/indy/config" ]; then
echo "Missing config directory, must be mounted"
exit 1
fi
if [ -f "/home/indy/config/genesis.txn" ]; then
echo "Genesis transactions file already exists"
exit
fi

if [ ! -z "$IPS" ]; then
echo von_generate_transactions -s "$IPS"
von_generate_transactions -s "$IPS"
elif [ ! -z "$IP" ]; then
echo von_generate_transactions -i "$IP"
von_generate_transactions -i "$IP"
else
echo von_generate_transactions
von_generate_transactions
fi

cp /home/indy/ledger/sandbox/pool_transactions_genesis /home/indy/config/genesis.txn
2 changes: 1 addition & 1 deletion scripts/manage
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage () {
- Any command and options that can be executed by the container's shell.
help
- Print this usage documantation.
- Print this usage documentation.
EOF
exit 1
Expand Down

0 comments on commit 9217324

Please sign in to comment.