Skip to content

Commit

Permalink
feat(localnet): Add --no-explorer flag and reduce size
Browse files Browse the repository at this point in the history
  • Loading branch information
abukosek committed Nov 21, 2024
1 parent 372c62f commit 02fefc1
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 163 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
SAPPHIRE_PARATIME: ${{ github.workspace }}/oasis_core/sapphire-paratime
OASIS_NODE_DATADIR: /tmp/oasis-sapphire-benchmarks
OASIS_WEB3_GATEWAY: ${{ github.workspace }}/oasis-web3-gateway
OASIS_DOCKER_START_EXPLORER: no
timeout-minutes: 30
steps:
- name: Checkout code
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
GATEWAY__CHAIN_ID: 42260
EMERALD_PARATIME: ${{ github.workspace }}/oasis_core/emerald-paratime
OASIS_NODE_DATADIR: /tmp/eth-runtime-test
OASIS_DOCKER_START_EXPLORER: no
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -116,6 +117,7 @@ jobs:
KEYMANAGER_ARTIFACT_URL: https://buildkite.com/organizations/oasisprotocol/pipelines/oasis-core-ci/builds/14038/jobs/0191c151-b95b-402c-9854-4e58effc95ab/artifacts/0191c156-f366-45b2-819b-e1eb9fd9ba16 # Find this at https://buildkite.com/oasisprotocol/oasis-core-ci/builds?branch=stable%2F<...> under "Build runtimes": simple-keymanager.mocksgx.
KEYMANAGER_BINARY: ${{ github.workspace }}/oasis_core/simple-keymanager
OASIS_NODE_DATADIR: /tmp/eth-runtime-test
OASIS_DOCKER_START_EXPLORER: no
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
File renamed without changes.
57 changes: 33 additions & 24 deletions docker/common/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

rm -f /CONTAINER_READY

export OASIS_DOCKER_START_EXPLORER=${OASIS_DOCKER_START_EXPLORER:-yes}

export OASIS_DOCKER_NO_GATEWAY=${OASIS_DOCKER_NO_GATEWAY:-no}

export OASIS_NODE_LOG_LEVEL=${OASIS_NODE_LOG_LEVEL:-warn}
Expand Down Expand Up @@ -148,6 +150,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--no-explorer)
# Don't start explorer and indexer.
OASIS_DOCKER_START_EXPLORER="no"
shift
;;
*)
echo "Unknown argument: $1"
exit 1;
Expand Down Expand Up @@ -351,35 +358,37 @@ else
sleep 10
fi

# Once everything is initialized and setup, start Nexus and Explorer.
if [ ! -z "${OASIS_NEXUS_BINARY:-}" ]; then
notice "Creating database 'nexus'\n"
su -c "createdb -h 127.0.0.1 -p 5432 -U postgres nexus" postgres
# Once everything is initialized and setup, start Nexus and Explorer if enabled.
if [[ "${OASIS_DOCKER_START_EXPLORER}" == "yes" ]]; then
if [ ! -z "${OASIS_NEXUS_BINARY:-}" ]; then
notice "Creating database 'nexus'\n"
su -c "createdb -h 127.0.0.1 -p 5432 -U postgres nexus" postgres

notice "Waiting for Nexus to start"
# Configure Nexus config file.
chain_context=$(${OASIS_NODE_BINARY} control status -a unix:${OASIS_NODE_SOCKET} | jq -r .consensus.chain_context)
sed -i 's/{{CHAIN_CONTEXT}}/'"${chain_context}"'/g' ${OASIS_NEXUS_CONFIG_FILE}
sed -i 's/{{LOG_LEVEL}}/'"${OASIS_NODE_LOG_LEVEL}"'/g' ${OASIS_NEXUS_CONFIG_FILE}
sed -i 's/{{PARATIME_NAME}}/'"${PARATIME_NAME}"'/g' ${OASIS_NEXUS_CONFIG_FILE}
notice "Waiting for Nexus to start"
# Configure Nexus config file.
chain_context=$(${OASIS_NODE_BINARY} control status -a unix:${OASIS_NODE_SOCKET} | jq -r .consensus.chain_context)
sed -i 's/{{CHAIN_CONTEXT}}/'"${chain_context}"'/g' ${OASIS_NEXUS_CONFIG_FILE}
sed -i 's/{{LOG_LEVEL}}/'"${OASIS_NODE_LOG_LEVEL}"'/g' ${OASIS_NEXUS_CONFIG_FILE}
sed -i 's/{{PARATIME_NAME}}/'"${PARATIME_NAME}"'/g' ${OASIS_NEXUS_CONFIG_FILE}

${OASIS_NEXUS_BINARY} --config ${OASIS_NEXUS_CONFIG_FILE} 2>1 &>/var/log/nexus.log &
NEXUS_PID=$!
${OASIS_NEXUS_BINARY} --config ${OASIS_NEXUS_CONFIG_FILE} 2>1 &>/var/log/nexus.log &
NEXUS_PID=$!

# Wait for Oasis Nexus to start.
while ! curl -s http://localhost:8547/ 2>1 &>/dev/null; do echo -n .; sleep 1; done
echo
fi
# Wait for Oasis Nexus to start.
while ! curl -s http://localhost:8547/ 2>1 &>/dev/null; do echo -n .; sleep 1; done
echo
fi

if [ ! -z "${OASIS_EXPLORER_DIR:-}" ]; then
notice "Waiting for Explorer to start"
cd ${OASIS_EXPLORER_DIR}
serve -s ${OASIS_EXPLORER_DIR} -l ${EXPLORER_PORT} > /var/log/explorer.log 2>&1 &
EXPLORER_PID=$!
if [ ! -z "${OASIS_EXPLORER_DIR:-}" ]; then
notice "Waiting for Explorer to start"
cd ${OASIS_EXPLORER_DIR}
serve -s ${OASIS_EXPLORER_DIR} -l ${EXPLORER_PORT} > /var/log/explorer.log 2>&1 &
EXPLORER_PID=$!

# Wait for Explorer to start.
while ! curl -s http://localhost:${EXPLORER_PORT}/ 2>1 &>/dev/null; do echo -n .; sleep 1; done
echo
# Wait for Explorer to start.
while ! curl -s http://localhost:${EXPLORER_PORT}/ 2>1 &>/dev/null; do echo -n .; sleep 1; done
echo
fi
fi

# Add Localnet to Oasis CLI and make it default.
Expand Down
Loading

0 comments on commit 02fefc1

Please sign in to comment.