catapult-rest
catapult-rest copied to clipboard
Convert rest to a npm installable lib or a binary
Atm, catapult-rest is installed (in the docker image or in a node) like it's a dev machine. In the manual node setup process (not bootstrap), the node admin needs to clone the repo, install nodejs, npm install and run the inde.js script (like a regular developer).
I would like to change this so catapult rest can be installed with an npm install -g command (like a cli tool) or by downloading prepackaged binaries (like we have with the supernode agent).
Also, it's not easy to run rest in different working dirs using relative paths to configuration and server certificates. We would need to improve this. If we do this, Bootstrap can be used for barebone configuration without updating the current docker-compose absolute paths used in the rest.json
https://github.com/nemtech/symbol-bootstrap/blob/main/config/rest-gateway/rest.json.mustache#L38
why
? that doesn't make much sense imo, especially that (besides docker) in most cases you probably do NOT want to do npm install **-g**
My thinking,
The current option is like described in https://deploy-preview-623--nemtech.netlify.app/guides/network/running-a-symbol-node-manually.html#build-and-run-the-rest-gateway. It's pretty much a development setup in a target node/image
A node/target machine (or a new docker image) needs to:
Option A) Git clone. Current one:
- Install nodejs
- Install git
- install yarn
- Clone repo
- Check out the right tag like v.2.3.5 (@segfaultxavi this is missed in the manual rest doc)
- Go to the repo folder, ./yarn_setup.sh
- Go to the ./rest folder , yarn build
- node _build/index.js resources/rest.json (not easy to run in different working dirs and different rest.json paths)
Upgrades: checkout the new tag and rebuild everything.
Option B) NPM dependency:
- Install nodejs
- npm install -g [email protected]
- catapult-rest mypathto/rest.json
Upgrades: npm install -g catapult-rest@latest/aNewVersion
Option C) Pre-packaged binaries:
Similar to how node admins can install the agents manually. https://docs.symbolplatform.com/guides/network/supernode-enrollment.html#manually
- wget https://catapult-rest.someurl.amazonaws.com/packages/2.3.5/catapult-rest-linux.bin
- chmod +x catapult-rest-linux.bin
- ./catapult-rest-linux.bin mypathto/rest.json
Upgrades: wget the new binary from the latest url
With C, the rest docker image can be standard ubuntu with just a binary file. It's faster to download, tthe base image would be shared between rest and server.
This is not a change I would like to implement so soon. We may be doing it while doing the rest typescript, catbuffer, and shared SDK refactoring.