Skip to content

Commit

Permalink
Do not depend on Go to be installed on the host to create snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
karimodm committed Nov 1, 2023
1 parent f435184 commit d3cf8d0
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions tools/docker-network/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ fi

REPLICAS=${1:-1}
MONITORING=${2:-0}
FEATURE=${3:-0}

DOCKER_COMPOSE_FILE=docker-compose.yml
if [ $FEATURE -ne 0 ]; then
DOCKER_COMPOSE_FILE=docker-compose-feature.yml
fi

export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
Expand All @@ -34,7 +28,7 @@ fi

# Allow docker compose to build and cache an image
echo $DOCKER_BUILD_CONTEXT $DOCKERFILE_PATH
docker compose -f $DOCKER_COMPOSE_FILE build --build-arg WITH_GO_WORK=${WITH_GO_WORK:-0} --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}
docker compose build --build-arg WITH_GO_WORK=${WITH_GO_WORK:-0} --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}

docker compose pull inx-indexer inx-blockissuer inx-faucet inx-validator-1

Expand All @@ -46,18 +40,23 @@ fi

# create snapshot file
echo "Create snapshot"
if [ $FEATURE -ne 0 ]; then
pushd ../genesis-snapshot
go run -tags=rocksdb . --config feature
else
pushd ../genesis-snapshot
go run -tags=rocksdb . --config docker --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih
fi
popd
mv ../genesis-snapshot/*.snapshot .

# Run Go command in Docker container
docker run --rm \
--user $(id -u) \
-v "$(realpath $(pwd)/../../):/workspace" \
-v "$(go env GOCACHE):/go-cache" \
-v "$(go env GOMODCACHE):/go-mod-cache" \
-e GOCACHE="/go-cache" \
-e GOMODCACHE="/go-mod-cache" \
-w "/workspace/tools/genesis-snapshot" \
golang:1.21 go run -tags=rocksdb . --config docker --seed 7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih

# Move and set permissions for the .snapshot file
mv -f ../genesis-snapshot/*.snapshot .
chmod o+r *.snapshot

echo "Run iota-core network with ${DOCKER_COMPOSE_FILE}"
echo "Run iota-core network"
# IOTA_CORE_PEER_REPLICAS is used in docker-compose.yml to determine how many replicas to create
export IOTA_CORE_PEER_REPLICAS=$REPLICAS
# Profiles is created to set which docker profiles to run
Expand All @@ -68,7 +67,7 @@ if [ $MONITORING -ne 0 ]; then
fi

export COMPOSE_PROFILES=$(join , ${PROFILES[@]})
docker compose -f $DOCKER_COMPOSE_FILE up
docker compose up

echo "Clean up docker resources"
docker compose down -v
Expand Down

0 comments on commit d3cf8d0

Please sign in to comment.