-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(localnet): Add --no-explorer flag and reduce size #653
base: main
Are you sure you want to change the base?
Conversation
7a30d81
to
3ec05bd
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #653 +/- ##
=======================================
Coverage 59.01% 59.01%
=======================================
Files 40 40
Lines 4384 4384
=======================================
Hits 2587 2587
Misses 1574 1574
Partials 223 223 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass, I'll test it tomorrow.
|
||
# Create symlinks for convenience and a dir to put all your rofls into, | ||
# also print version info. | ||
RUN ln -s ${OASIS_NODE_BINARY} ${OASIS_CLI_BINARY} /usr/local/bin \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also link the web3 gateway there for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's useful, since the gateway is started at container startup if enabled and the user won't ever need to call it manually, whereas the CLI and node have useful commands. This is probably why the original author of these links only linked the node and CLI :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor suggestions. The updates to sapphire-localnet/Dockerfile are great, much clearer what versions of components are used.
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this to OASIS_DOCKER_START_GATEWAY
, for consistency with explorer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I just remembered that enabling nexus/explorer while gateway is disabled wont work, so let's maybe catch that and error out (or alternative, if gateway is disabled also automatically disable nexus/explorer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll fix that :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this to
OASIS_DOCKER_START_GATEWAY
, for consistency with explorer?
I've kept this as-is for compatibility, but we can do a separate PR to change this in the future.
@@ -148,6 +150,11 @@ while [[ $# -gt 0 ]]; do | |||
shift | |||
shift | |||
;; | |||
--no-explorer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add a flag for disabling gateway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply disable both the explorer and indexer, if --no-explorer
is passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply disable both the explorer and indexer, if
--no-explorer
is passed.
That is already what happens, Peter suggested adding a similar option for the gateway :)
docker/common/start.sh
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this check for the binary now and assume it's set if explorer is enabled? (like we do for gateway).
docker/sapphire-localnet/Dockerfile
Outdated
\ | ||
&& cd / \ | ||
&& if [ "x${OASIS_CORE_BRANCH}" != "x" ]; then \ | ||
git clone https://github.com/oasisprotocol/oasis-core.git --branch ${OASIS_CORE_BRANCH} --depth 1 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a pattern that allows specifying either branch name or commit ref, and works in both cases?
I believe the clone->fetch->checkout as it is done for Explorer repository works with both. Maybe there's a more concise alternative, but it would be great if we would allow either branch name or specific commit refs to be specified for any component.
docker/sapphire-localnet/Dockerfile
Outdated
# ARG EXPLORER_REPO=https://github.com/oasisprotocol/explorer.git | ||
# ARG EXPLORER_VERSION=v1.13.0 | ||
#ARG NEXUS_BRANCH=main | ||
|
||
# TODO: Update to a released version once a version with localnet explorer support is available (https://github.com/oasisprotocol/explorer/issues/1597). | ||
ARG EXPLORER_REPO=https://github.com/oasisprotocol/explorer.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to remove the variable for the repository. I used it because my (very hacky) fork was used before explorer got some real support for localnet in oasisprotocol/explorer#1597 , but then forgot to remove it 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, can you also move the explorer port 80 to 8548 (see the last bullet #640) and the docs accordingly.
@@ -148,6 +150,11 @@ while [[ $# -gt 0 ]]; do | |||
shift | |||
shift | |||
;; | |||
--no-explorer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply disable both the explorer and indexer, if --no-explorer
is passed.
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to describe the usage in the Sapphire Localnet chapter: https://github.com/oasisprotocol/docs/blob/main/docs/dapp/tools/localnet.mdx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR opened in docs: oasisprotocol/docs#1032
3ec05bd
to
d39e59d
Compare
Ready for re-review :) In a future PR, we can replace nodejs with nginx and save about 200MB+. |
This PR:
--no-explorer
flag, which disables starting the explorer and indexer.--no-gateway
flag, which disables starting the gateway.Closes #640.