-
Notifications
You must be signed in to change notification settings - Fork 21
Development Guide
The purpose of this guide is to help developers establish a BrightID-Node workflow.
To pull the official arangodb image from https://hub.docker.com/_/arangodb/ , execute
docker pull arangodbSelect a local directory as a bind mount for the foxx application directory. This directory must exist on your local filesystem. For example: FOXX_APPS=/home/docker/brightid/arangodb-apps. If you're using macOS, you might need to add that directory to the "File Sharing" tab so it can be bind mounted.
The following command will create a volume named "arangodb" to hold the DB files, so they persist even if the container is removed or updated. It creates a bind mount for the foxx application directory to the local foxx directory, so you can work on the foxx apps outside of docker.
docker run -d -e ARANGO_NO_AUTH=1 -e ARANGO_STORAGE_ENGINE=rocksdb -p 8529:8529 -v arangodb:/var/lib/arangodb3 -v $FOXX_APPS:/var/lib/arangodb3-apps --name arango arangodbIn the https://github.com/BrightID/BrightID-Node/tree/master/db directory, there is a schema directory that contains dumps of all the db collection schemas. Copy this schema directory into the $FOXX_APPS directory on the same level as the pre-existing _db directory.
Enter the container by running
docker exec -it arango /bin/sh
Change directories
cd /var/lib/arangodb3-apps
You should see the schema directory you just copied
ls
Run the following command to restore the collections.
arangorestore --import-data false schema
It will prompt for a password; just hit enter. (The container was created with ARANGO_NO_AUTH=1.)
open http://localhost:8529 in your browser
Go to "Services", "Add Service" and "Upload" the brightid_4.0.0.zip file from https://github.com/BrightID/BrightID-Node/tree/master/web_services/foxx, and then "Install" the service and use /brightid as "Mount Point".
Under "Settings" in the brightid service, set the required "ip" setting to "localhost".
You should also upload and install apply_4.0.0.zip file from the same path in the same way and use /apply as "Mount Point".
The brightid service provides a public API with different endpoints for BrightID mobile clients, but the apply service provides an internal API with a single endpoint for consensus service run by BrightID Node.
Consensus service use the apply service to apply operations to the database after all the nodes in BrightID network reached consensus over the operation. To avoid redundancy in coding, both brightid and apply services share the same js modules and the only difference between them is that:
-
applydoesn't have tests folder (thetests/operations.jsinbrightidtest this service too) -
applyhas a differentmanifest.jsonfile - The
manifest.jsonforapplyuseapply.jsas main script for specifying endpoints
Under "Settings" in the both of brightid and apply services, turn on development mode using "Set Development."
In the $FOXX_APPS directory, navigate to the _db\_system\brightid\APP sub-directory. Make changes to the javascript files, including tests.
When a js file is (not required for tests) changed, update the _db\_system\apply\APP folder with the new changed js file and keep apply and brightid js files exactly the same.
To run tests, go to "Settings" in the brightid service and click the beaker icon. To test the API, go to "API".
It's helpful to have two tabs open:
- http://localhost:8529/_db/_system/_admin/aardvark/index.html#service/%2Fbrightid* open to the API tab for testing the API or the Settings tab for running tests
- http://localhost:8529/_db/_system/_admin/aardvark/index.html#logs
Whenever you make a change, restart "arango" container using docker container restart arango. Then go to the first tab to test your change. If something doesn't seem right, go to the second tab and check the log for errors.
- Under "Settings" for both
brightidandapplyservices, click "download" to download .zip files. - Navigate to your local clone of the https://github.com/BrightID/BrightID-Node/tree/master/web_services/foxx directory.
- Delete the existing
brightid_*directory. - Unzip the .zip file to create a new
brightid_*directory. - Replace old brightid_.zip and apply_.zip files with downloaded files.
- Commit and push to Github.
git clone https://github.com/BrightID/BrightID-Node
cd BrightID-Node
Or
cd BrightID-Node
git pull
docker-compose build
docker-compose up -d