diff --git a/stack-orchestrator/compose/docker-compose-testnet-onboarding-api.yml b/stack-orchestrator/compose/docker-compose-testnet-onboarding-api.yml new file mode 100644 index 0000000..2d9fc68 --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-testnet-onboarding-api.yml @@ -0,0 +1,21 @@ +services: + testnet-onboarding-api: + restart: unless-stopped + image: cerc/testnet-onboarding-api:local + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + SUMSUB_APP_TOKEN: ${SUMSUB_APP_TOKEN} + SUMSUB_SECRET_KEY: ${SUMSUB_SECRET_KEY} + KYC_LEVEL: ${KYC_LEVEL:-basic-kyc-level} + TTL_IN_SECS: ${TTL_IN_SECS:-600} + command: ["bash", "./run.sh"] + volumes: + - ../config/api/run.sh:/app/run.sh + ports: + - 3000 + healthcheck: + test: ["CMD", "nc", "-vz", "127.0.0.1", "3000"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 5s diff --git a/stack-orchestrator/config/api/run.sh b/stack-orchestrator/config/api/run.sh new file mode 100755 index 0000000..41bbb5f --- /dev/null +++ b/stack-orchestrator/config/api/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +echo "Using the following env variables:" +echo "SUMSUB_APP_TOKEN: ${SUMSUB_APP_TOKEN}" +echo "SUMSUB_SECRET_KEY: ${SUMSUB_SECRET_KEY}" +echo "KYC_LEVEL: ${KYC_LEVEL}" +echo "TTL_IN_SECS: ${TTL_IN_SECS}" + +SUMSUB_APP_TOKEN=$SUMSUB_APP_TOKEN \ +SUMSUB_SECRET_KEY=$SUMSUB_SECRET_KEY \ +KYC_LEVEL=$KYC_LEVEL \ +TTL_IN_SECS=$TTL_IN_SECS \ +node dist/index.js diff --git a/stack-orchestrator/config/app/onboarding-app-start.sh b/stack-orchestrator/config/app/onboarding-app-start.sh old mode 100644 new mode 100755 diff --git a/stack-orchestrator/container-build/cerc-testnet-onboarding-api/build.sh b/stack-orchestrator/container-build/cerc-testnet-onboarding-api/build.sh new file mode 100755 index 0000000..bb021fc --- /dev/null +++ b/stack-orchestrator/container-build/cerc-testnet-onboarding-api/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Build cerc/testnet-onboarding-api + +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/testnet-onboarding-api:local ${build_command_args} ${CERC_REPO_BASE_DIR}/testnet-onboarding-api diff --git a/stack-orchestrator/stacks/onboarding-api/README.md b/stack-orchestrator/stacks/onboarding-api/README.md new file mode 100644 index 0000000..3532434 --- /dev/null +++ b/stack-orchestrator/stacks/onboarding-api/README.md @@ -0,0 +1,107 @@ +# onboarding-api + +Instructions for running the `testnet-onboarding-api` using [laconic-so](https://git.vdb.to/cerc-io/stack-orchestrator) + +## Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/testnet-onboarding-app-stack + ``` + +* Setup required repositories: + + ```bash + laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api setup-repositories + ``` + +* Build the container image: + + ```bash + laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api build-containers + ``` + + This should create the `cerc/testnet-onboarding-api` image locally + +## Create a deployment + +* Create a spec file for the deployment: + + ```bash + laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-api deploy init --output onboarding-api-spec.yml + ``` + +* Edit `network` in the spec file to map container ports to host ports as required: + + ```bash + network: + ports: + testnet-onboarding-api: + - '3000:3000' + ``` + +* Create a deployment from the spec file: + + ```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 + ``` + +## Configuration + +* Inside the `onboarding-api-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + # Your sumsub application token + SUMSUB_APP_TOKEN= + + # Your sumsub secret key + SUMSUB_SECRET_KEY= + + # Optional + + # KYC level of access token being generated (default: basic-kyc-level) + KYC_LEVEL= + + # TTL for the generated access token in seconds (default: 600) + 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 + # With status + docker ps + + # Check logs for the server + laconic-so deployment --dir onboarding-api-deployment logs -f testnet-onboarding-api + ``` + +## Run + +* 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: + # {"token":"generated-access-token"} + ``` + +## Clean up + +* Stop the deployment: + + ```bash + laconic-so deployment --dir onboarding-api-deployment stop + ``` diff --git a/stack-orchestrator/stacks/onboarding-api/stack.yml b/stack-orchestrator/stacks/onboarding-api/stack.yml new file mode 100644 index 0000000..f027b4b --- /dev/null +++ b/stack-orchestrator/stacks/onboarding-api/stack.yml @@ -0,0 +1,9 @@ +version: "1.0" +name: onboarding-api +description: "Testnet onboarding API" +repos: + - git.vdb.to/cerc-io/testnet-onboarding-api +containers: + - cerc/testnet-onboarding-api +pods: + - testnet-onboarding-api