2024-07-26 06:31:40 +00:00
# onboarding-api
Instructions for running the `testnet-onboarding-api` using [laconic-so ](https://git.vdb.to/cerc-io/stack-orchestrator )
2024-07-31 10:25:18 +00:00
## Prerequisite
* `laconic-so` : [installation ](https://git.vdb.to/cerc-io/stack-orchestrator#install ) instructions
* sumsub application token: < https: // docs . sumsub . com / docs / app-tokens >
2024-07-26 06:31:40 +00:00
## Setup
2024-07-31 10:25:18 +00:00
* Fetch the stack repo:
2024-07-26 06:31:40 +00:00
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/testnet-onboarding-app-stack
```
2024-07-31 10:25:18 +00:00
This should clone the stack repo in `$HOME/cerc` directory
2024-07-26 06:31:40 +00:00
* Setup required repositories:
```bash
2024-07-31 10:25:18 +00:00
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api setup-repositories --pull
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories and re-run the command
# The repositories are located in $HOME/cerc by default
2024-07-26 06:31:40 +00:00
```
* Build the container image:
```bash
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api build-containers
```
2024-07-31 10:25:18 +00:00
This should create the `cerc/testnet-onboarding-api` Docker image locally, same can be confirmed by running `docker image ls`
2024-07-26 06:31:40 +00:00
## Create a deployment
* Create a spec file for the deployment:
```bash
2024-07-31 10:25:18 +00:00
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api deploy init --map-ports-to-host any-same --output onboarding-api-spec.yml
2024-07-26 06:31:40 +00:00
```
2024-07-31 10:25:18 +00:00
* This should create the spec file `onboarding-api-spec.yml`
* The port mapping option `any-same` binds the ports for Docker services to `0.0.0.0` on the host machine; edit the spec file to change the mapping as desired
2024-07-26 06:31:40 +00:00
2024-07-31 10:25:18 +00:00
* Create an `onboarding-api` stack deployment from the spec file:
2024-07-26 06:31:40 +00:00
```bash
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api deploy create --spec-file onboarding-api-spec.yml --deployment-dir onboarding-api-deployment
```
2024-07-31 10:25:18 +00:00
* This should create the deployment directory `onboarding-api-deployment`
* Note: Once a deployment is created from the spec file, the port mappings are set in Docker compose files; in order to change the port mapping after that, the deployment has to be re-created with a modified spec file
2024-07-26 06:31:40 +00:00
## Configuration
2024-07-31 10:25:18 +00:00
* Inside the `onboarding-api-deployment` deployment directory, open `config.env` and set following env variables:
2024-07-26 06:31:40 +00:00
```bash
# Your sumsub application token
SUMSUB_APP_TOKEN=
# Your sumsub secret key
SUMSUB_SECRET_KEY=
# Optional
2024-07-31 10:25:18 +00:00
# Default KYC level of access token being generated (default: basic-kyc-level)
2024-07-26 06:31:40 +00:00
KYC_LEVEL=
2024-07-31 10:25:18 +00:00
# Default TTL for the generated access token in seconds (default: 600)
2024-07-26 06:31:40 +00:00
TTL_IN_SECS=
```
## Start the deployment
```bash
laconic-so deployment --dir onboarding-api-deployment start
```
## Check status
* To list down and monitor the running container:
```bash
docker ps
2024-07-31 10:25:18 +00:00
# Ensure that the testnet-onboarding-api container is healthy
2024-07-26 06:31:40 +00:00
# Check logs for the server
laconic-so deployment --dir onboarding-api-deployment logs -f testnet-onboarding-api
```
2024-07-31 10:25:18 +00:00
## Example
2024-07-26 06:31:40 +00:00
* Generate an access token for a user:
```bash
curl -X POST http://localhost:3000/generate-token \
-H "Content-Type: application/json" \
-d '{"userId": "JamesBond007"}'
# Expected output:
2024-07-31 10:25:18 +00:00
# {"token":"< generated-access-token > "}
2024-07-26 06:31:40 +00:00
```
## Clean up
* Stop the deployment:
```bash
laconic-so deployment --dir onboarding-api-deployment stop
```