Add stacks for testnet-onboarding-app and testnet-onboarding-api #1

Merged
nabarun merged 4 commits from pm-add-app-stack into main 2024-07-26 06:31:41 +00:00
5 changed files with 199 additions and 0 deletions
Showing only changes of commit 8a22b4fd47 - Show all commits

View File

@ -0,0 +1,26 @@
services:
# Builds and serves the React testnet-onboarding-app
testnet-onboarding-app:
restart: unless-stopped
image: cerc/testnet-onboarding-app:local
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
WALLET_CONNECT_ID: ${WALLET_CONNECT_ID}
CERC_LACONICD_CHAIN_ID: ${CERC_LACONICD_CHAIN_ID:-laconic_9000-1}
CERC_REGISTRY_GQL_ENDPOINT: ${CERC_REGISTRY_GQL_ENDPOINT:-http://localhost:9473/api}
CERC_LACONICD_RPC_ENDPOINT: ${CERC_LACONICD_RPC_ENDPOINT:-http://localhost:26657}
CERC_LACONICD_DENOM: ${CERC_LACONICD_DENOM:-photon}
CERC_FAUCET_ENDPOINT: ${CERC_FAUCET_ENDPOINT:-http://localhost:4000}
CERC_WALLET_META_URL: ${CERC_WALLET_META_URL:-http://localhost:3000}
working_dir: /scripts
command: ["bash", "onboarding-app-start.sh"]
volumes:
- ../config/app/onboarding-app-start.sh:/scripts/onboarding-app-start.sh
ports:
- "80"
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "80"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
echo "Using the following env variables:"
echo "WALLET_CONNECT_ID: ${WALLET_CONNECT_ID}"
echo "CERC_LACONICD_CHAIN_ID: ${CERC_LACONICD_CHAIN_ID}"
echo "CERC_REGISTRY_GQL_ENDPOINT: ${CERC_REGISTRY_GQL_ENDPOINT}"
echo "CERC_LACONICD_RPC_ENDPOINT: ${CERC_LACONICD_RPC_ENDPOINT}"
echo "CERC_LACONICD_DENOM: ${CERC_LACONICD_DENOM}"
echo "CERC_FAUCET_ENDPOINT: ${CERC_FAUCET_ENDPOINT}"
echo "CERC_WALLET_META_URL: ${CERC_WALLET_META_URL}"
# Build with required env
REACT_APP_WALLET_CONNECT_ID= $WALLET_CONNECT_ID \
REACT_APP_ETHEREUM_MAINNET_CHAIN_ID=1 \
REACT_APP_LACONICD_CHAIN_ID=$LACONICD_CHAIN_ID \
REACT_APP_REGISTRY_GQL_ENDPOINT=$REGISTRY_GQL_ENDPOINT \
REACT_APP_LACONICD_RPC_ENDPOINT=$LACONICD_RPC_ENDPOINT \
REACT_APP_LACONICD_DENOM=$LACONICD_DENOM \
REACT_APP_FAUCET_ENDPOINT=$FAUCET_ENDPOINT \
REACT_APP_WALLET_META_URL=$WALLET_META_URL \
yarn build
http-server -p 80 /app/build

View File

@ -0,0 +1,43 @@
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=18-bullseye
FROM node:${VARIANT}
ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
# Prevents npm from printing version warnings
ENV NPM_CONFIG_UPDATE_NOTIFIER=false
RUN \
# Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \
&& touch /usr/local/etc/npmrc \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
&& npm cache clean --force > /dev/null 2>&1
# Install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends jq bash netcat
RUN mkdir -p /scripts
# Install simple web server for now (use nginx perhaps later)
RUN yarn global add http-server
WORKDIR /app
COPY . .
RUN yarn install
# Expose port for http
EXPOSE 80

View File

@ -0,0 +1,93 @@
# onboarding-app
Instructions for running the `testnet-onboarding-app` 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-app setup-repositories
```
* Build the container image:
```bash
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-app build-containers
```
This should create the `cerc/testnet-onboarding-app` 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-app deploy init --output onboarding-app-spec.yml
```
* Edit `network` in the spec file to map container ports to host ports as required:
```bash
network:
ports:
testnet-onboarding-app:
- '3000:80'
```
* Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/testnet-onboarding-app-stack/stack-orchestrator/stacks/onboarding-app deploy create --spec-file onboarding-app-spec.yml --deployment-dir onboarding-app-deployment
```
## Configuration
* Inside the `onboarding-app-deployment` deployment directory, open `config.env` file and set following env variables:
```bash
# WalletConnect project ID, same should be used in the laconic-wallet
WALLET_CONNECT_ID=
# Optional
# laconicd chain id (default: laconic_9000-1)
CERC_LACONICD_CHAIN_ID=
# laconicd registry GQL endpoint (default: http://localhost:9473/api)
CERC_REGISTRY_GQL_ENDPOINT=
# laconicd RPC endpoint (default: http://laconicd:26657)
CERC_LACONICD_RPC_ENDPOINT=
# laconicd token denom (default: photon)
CERC_LACONICD_DENOM=
# Faucet RPC endpoint (default: http://localhost:4000)
CERC_FAUCET_ENDPOINT=
# laconic wallet meta URL (default: http://localhost:3000)
CERC_WALLET_META_URL=
```
## Start the deployment
```bash
laconic-so deployment --dir onboarding-app-deployment start
```
Open the app in a browser at <http://localhost:3000>
## Clean up
* Stop the deployment:
```bash
laconic-so deployment --dir onboarding-app-deployment stop
```

View File

@ -0,0 +1,9 @@
version: "1.0"
name: onboarding-app
description: "Testnet onboarding app"
repos:
- git.vdb.to/cerc-io/testnet-onboarding-app
containers:
- cerc/testnet-onboarding-app
pods:
- testnet-onboarding-app