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 25, 2024
1 parent 502678f commit d39e59d
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 147 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
4 changes: 4 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ be funded 10,000 TEST. Flags `-amount`, `-to`, `-n` can be added to specify an
initial ROSE deposit, existing mnemonic and the number of addresses to derive
and fund respectively.

By passing `--no-explorer`, the Explorer frontend and Nexus indexer won't be
started (useful if you want to reduce the container startup time a bit,
e.g. for CI tests).

WARNING: The image is running in *ephemeral mode*. A new chain state will be
initialized each time you start the container!

Expand Down
File renamed without changes.
23 changes: 19 additions & 4 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,13 +150,28 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--no-explorer)
# Don't start explorer and indexer.
OASIS_DOCKER_START_EXPLORER="no"
shift
;;
--no-gateway)
# Don't start web3 gateway.
OASIS_DOCKER_NO_GATEWAY="yes"
shift
;;
*)
echo "Unknown argument: $1"
exit 1;
;;
esac
done

if [[ "${OASIS_DOCKER_NO_GATEWAY}" == "yes" ]]; then
# If gateway is disabled, also disable explorer and indexer.
OASIS_DOCKER_START_EXPLORER="no"
fi

function populate_accounts() {
# Remove underscores from amount, as those are only there to make it easier
# for humans to parse the amount.
Expand Down Expand Up @@ -351,8 +368,8 @@ else
sleep 10
fi

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

Expand All @@ -369,9 +386,7 @@ if [ ! -z "${OASIS_NEXUS_BINARY:-}" ]; then
# 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 &
Expand Down
2 changes: 1 addition & 1 deletion docker/emerald-localnet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN wget https://github.com/oasisprotocol/nexus/releases/download/v${NEXUS_VERSI
# TODO: update once some support for localnet is added: https://github.com/oasisprotocol/explorer/issues/1597
ARG EXPLORER_REPO=https://github.com/oasisprotocol/explorer.git
ARG EXPLORER_VERSION=bcb125108db2f6439fcdd536f690b0edfd38aad7
COPY docker/common/explorer.env /nexus.env.production
COPY docker/common/nexus.env.production /nexus.env.production
RUN git clone ${EXPLORER_REPO} explorer --depth 1 \
&& cd explorer \
&& git fetch origin ${EXPLORER_VERSION} --depth 1 \
Expand Down
Loading

0 comments on commit d39e59d

Please sign in to comment.