catapult-rest icon indicating copy to clipboard operation
catapult-rest copied to clipboard

Convert rest to a npm installable lib or a binary

Open fboucquez opened this issue 3 years ago • 2 comments

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

fboucquez avatar Mar 24 '21 14:03 fboucquez

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**

gimre-xymcity avatar Mar 25 '21 13:03 gimre-xymcity

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:

  1. Install nodejs
  2. Install git
  3. install yarn
  4. Clone repo
  5. Check out the right tag like v.2.3.5 (@segfaultxavi this is missed in the manual rest doc)
  6. Go to the repo folder, ./yarn_setup.sh
  7. Go to the ./rest folder , yarn build
  8. 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:

  1. Install nodejs
  2. npm install -g [email protected]
  3. 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

  1. wget https://catapult-rest.someurl.amazonaws.com/packages/2.3.5/catapult-rest-linux.bin
  2. chmod +x catapult-rest-linux.bin
  3. ./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.

fboucquez avatar Mar 25 '21 15:03 fboucquez