1
0

Use standalone mobymask-v2-watcher-ts for running watcher server (#327)

* Use standalone mobymask-v2-watcher-ts to run peer test

* Add watcher-ts image for running peer tests

* Run separate containers for peer ids generation and tests

* Wait for watcher to be up before starting peer-test-app

* Resolve peer-test-app compose file and remove setup-repositories for web-apps

Former-commit-id: c4002dcc5c5001d3b45cda334bcc64929a1c7dbc
This commit is contained in:
Nabarun Gogoi 2023-04-19 13:48:51 +05:30 committed by GitHub
parent 4caae1d850
commit 53fbc60f55
16 changed files with 103 additions and 63 deletions

View File

@ -10,8 +10,12 @@ services:
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_RELAY_NODES: ${CERC_RELAY_NODES}
command: ["sh", "./test-app-start.sh"]
command:
- sh
- -c
- ./wait-for-it.sh -h ${CERC_WATCHER_HOST:-$${DEFAULT_CERC_WATCHER_HOST}} -p ${CERC_WATCHER_PORT:-$${DEFAULT_CERC_WATCHER_PORT}} -s -t 0 -- ./test-app-start.sh
volumes:
- ../config/wait-for-it.sh:/scripts/wait-for-it.sh
- ../config/watcher-mobymask-v2/test-app-start.sh:/scripts/test-app-start.sh
- peers_ids:/peers
ports:

View File

@ -54,6 +54,18 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
# Creates peer-id files if they don't exist
peer-ids-gen:
image: cerc/watcher-ts:local
restart: on-failure
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
working_dir: /app/packages/peer
command: ["sh", "generate-peer-ids.sh"]
volumes:
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
- peers_ids:/peer-ids
# Starts the mobymask-v2-watcher server
mobymask-watcher-server:
image: cerc/watcher-mobymask-v2:local
@ -61,6 +73,8 @@ services:
depends_on:
mobymask-watcher-db:
condition: service_healthy
peer-ids-gen:
condition: service_completed_successfully
mobymask:
condition: service_completed_successfully
env_file:
@ -76,9 +90,9 @@ services:
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
command: ["sh", "start-server.sh"]
volumes:
- ../config/watcher-mobymask-v2/watcher-config-template.toml:/app/packages/mobymask-v2-watcher/environments/watcher-config-template.toml
- ../config/watcher-mobymask-v2/start-server.sh:/app/packages/mobymask-v2-watcher/start-server.sh
- peers_ids:/app/packages/mobymask-v2-watcher/peers
- ../config/watcher-mobymask-v2/watcher-config-template.toml:/app/environments/watcher-config-template.toml
- ../config/watcher-mobymask-v2/start-server.sh:/app/start-server.sh
- peers_ids:/app/peers
- mobymask_deployment:/server
- fixturenet_geth_accounts:/geth-accounts:ro
# Expose GQL, metrics and relay node ports
@ -95,6 +109,28 @@ services:
extra_hosts:
- "host.docker.internal:host-gateway"
# Container to run peer tests
peer-tests:
image: cerc/watcher-ts:local
restart: on-failure
depends_on:
mobymask-watcher-server:
condition: service_healthy
peer-ids-gen:
condition: service_completed_successfully
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
working_dir: /app/packages/peer
command:
- sh
- -c
- |
./set-tests-env.sh && \
tail -f /dev/null
volumes:
- ../config/watcher-mobymask-v2/set-tests-env.sh:/app/packages/peer/set-tests-env.sh
- peers_ids:/peer-ids
volumes:
mobymask_watcher_db_data:
peers_ids:

View File

@ -0,0 +1,20 @@
#!/bin/sh
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
# Check for peer ids in ./peers folder, create if not present
if [ -f /peer-ids/relay-id.json ]; then
echo "Using peer id for relay node from the mounted volume"
else
echo "Creating a new peer id for relay node"
yarn create-peer -f /peer-ids/relay-id.json
fi
if [ -f /peer-ids/peer-id.json ]; then
echo "Using peer id for peer node from the mounted volume"
else
echo "Creating a new peer id for peer node"
yarn create-peer -f /peer-ids/peer-id.json
fi

View File

@ -0,0 +1,10 @@
#!/bin/sh
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /peer-ids/relay-id.json)"
# Write the relay node's multiaddr to /app/packages/peer/.env for running tests
echo "RELAY=\"$CERC_RELAY_MULTIADDR\"" > ./.env

View File

@ -14,26 +14,7 @@ CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRA
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
# Check for peer ids in ./peers folder, create if not present
if [ -f ./peers/relay-id.json ]; then
echo "Using peer id for relay node from the mounted volume"
else
echo "Creating a new peer id for relay node"
cd ../peer
yarn create-peer -f ../mobymask-v2-watcher/peers/relay-id.json
cd ../mobymask-v2-watcher
fi
if [ -f ./peers/peer-id.json ]; then
echo "Using peer id for peer node from the mounted volume"
else
echo "Creating a new peer id for peer node"
cd ../peer
yarn create-peer -f ../mobymask-v2-watcher/peers/peer-id.json
cd ../mobymask-v2-watcher
fi
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' ./peers/relay-id.json)"
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /app/peers/relay-id.json)"
# Use contract address from environment variable or set from config.json in mounted volume
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
@ -65,8 +46,5 @@ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
# Write the modified content to a new file
echo "$WATCHER_CONFIG" > environments/local.toml
# Write the relay node's multiaddr to /app/packages/peer/.env for running tests
echo "RELAY=\"$CERC_RELAY_MULTIADDR\"" > /app/packages/peer/.env
echo 'yarn server'
yarn server

View File

@ -17,4 +17,4 @@ COPY . .
RUN echo "Building watcher-ts" && \
yarn && yarn build
WORKDIR /app/packages/mobymask-v2-watcher
WORKDIR /app

View File

@ -6,4 +6,4 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/watcher-mobymask-v2:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts
docker build -t cerc/watcher-mobymask-v2:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mobymask-v2-watcher-ts

View File

@ -0,0 +1,10 @@
FROM node:16.17.1-alpine3.16
RUN apk --update --no-cache add git python3 alpine-sdk jq
WORKDIR /app
COPY . .
RUN echo "Building watcher-ts" && \
yarn && yarn build

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/watcher-erc20
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/watcher-ts:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts

View File

@ -14,6 +14,7 @@ cerc/laconic-registry-cli
cerc/laconic-console-host
cerc/fixturenet-eth-geth
cerc/fixturenet-eth-lighthouse
cerc/watcher-ts
cerc/watcher-mobymask
cerc/watcher-erc20
cerc/watcher-erc721

View File

@ -10,6 +10,7 @@ laconicd
fixturenet-laconicd
fixturenet-eth
fixturenet-eth-metrics
watcher-ts
watcher-mobymask
watcher-erc20
watcher-erc721

View File

@ -12,6 +12,7 @@ cerc-io/laconic-registry-cli
cerc-io/laconic-console
cerc-io/mobymask-watcher
cerc-io/watcher-ts
cerc-io/mobymask-v2-watcher-ts
cerc-io/react-peer
cerc-io/mobymask-ui
cerc-io/MobyMask

View File

@ -23,15 +23,7 @@ Checkout to the required versions and branches in repos
```bash
# watcher-ts
cd ~/cerc/watcher-ts
git checkout v0.2.35
# react-peer
cd ~/cerc/react-peer
git checkout v0.2.32
# mobymask-ui
cd ~/cerc/mobymask-ui
git checkout v0.1.2
git checkout v0.2.39
# MobyMask
cd ~/cerc/MobyMask
@ -73,13 +65,13 @@ Deploy the stack:
Find the watcher container's id and export it for later use:
```bash
export CONTAINER_ID=$(docker ps -q --filter "name=mobymask-watcher-server")
export CONTAINER_ID=$(docker ps -q --filter "name=peer-tests")
```
Run the peer tests:
```bash
docker exec -w /app/packages/peer $CONTAINER_ID yarn test
docker exec $CONTAINER_ID yarn test
```
## Web Apps

View File

@ -66,7 +66,7 @@
* Get the deployed contract address:
```bash
docker exec -it $(docker ps -aq --filter name="mobymask-app") cat src/config.json
docker exec -it $(docker ps -aq --filter name="mobymask-app") cat /config/config.yml
```
The value of `address` field is the deployed contract address

View File

@ -6,8 +6,7 @@ repos:
- ethereum-optimism/optimism
- ethereum-optimism/op-geth
- cerc-io/watcher-ts
- cerc-io/react-peer
- cerc-io/mobymask-ui
- cerc-io/mobymask-v2-watcher-ts
- cerc-io/MobyMask
containers:
- cerc/go-ethereum
@ -19,6 +18,7 @@ containers:
- cerc/optimism-l2geth
- cerc/optimism-op-batcher
- cerc/optimism-op-node
- cerc/watcher-ts
- cerc/watcher-mobymask-v2
- cerc/react-peer
- cerc/mobymask-ui

View File

@ -6,26 +6,6 @@ Instructions to setup and deploy MobyMask and Peer Test web apps
Prerequisite: Watcher with GQL and relay node endpoints
Clone required repositories:
```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/react-peer,cerc-io/mobymask-ui
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Checkout to the required versions and branches in repos:
```bash
# react-peer
cd ~/cerc/react-peer
git checkout v0.2.32
# mobymask-ui
cd ~/cerc/mobymask-ui
git checkout v0.1.2
```
Build the container images:
```bash