Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web-apps and laconicd in MobyMask v2 watcher stack #226

Merged
merged 7 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/data/compose/docker-compose-mobymask-laconicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.2"

services:
laconicd:
restart: unless-stopped
image: cerc/laconicd:local
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
volumes:
- ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
ports:
- "9473"
- "8545"
- "8546"
- "1317"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "8545"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s

networks:
# https://docs.docker.com/compose/networking/#configure-the-default-network
default:
name: mobymask-v2-network
87 changes: 85 additions & 2 deletions app/data/compose/docker-compose-watcher-mobymask-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ services:
retries: 15
start_period: 10s

mobymask:
restart: unless-stopped
depends_on:
mobymask-watcher-db:
condition: service_healthy
image: cerc/mobymask:local
working_dir: /app/packages/server
environment:
- ENV=PROD
command: ["sh", "-c", "npm start"]
volumes:
- ../config/watcher-mobymask-v2/secrets.json:/app/packages/server/secrets.json
- moby_data_server:/app/packages/server
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3330"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s

mobymask-watcher-server:
restart: unless-stopped
depends_on:
Expand All @@ -30,18 +50,81 @@ services:
command: ["sh", "-c", "yarn server"]
volumes:
- ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml
- ../config/watcher-mobymask-v2/.env:/app/packages/peer/.env
- ../config/watcher-mobymask-v2/peer.env:/app/packages/peer/.env
- ../config/watcher-mobymask-v2/relay-id.json:/app/packages/mobymask-v2-watcher/relay-id.json
ports:
- "0.0.0.0:3001:3001"
- "0.0.0.0:9001:9001"
- "0.0.0.0:9090:9090"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "9090"]
test: ["CMD", "busybox", "nc", "localhost", "9090"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s

mobymask-watcher-peer:
restart: unless-stopped
depends_on:
mobymask:
condition: service_healthy
image: cerc/watcher-mobymask-v2:local
command: ["sh", "peer-start.sh"]
volumes:
- ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml
- ../config/watcher-mobymask-v2/peer-id.json:/app/packages/mobymask-v2-watcher/peer-id.json
- ../config/watcher-mobymask-v2/peer-start.sh:/app/packages/mobymask-v2-watcher/peer-start.sh
- moby_data_server:/server

mobymask-app:
depends_on:
mobymask-watcher-server:
condition: service_healthy
mobymask:
condition: service_healthy
image: cerc/mobymask-ui:local
command: ["sh", "mobymask-app-start.sh"]
volumes:
- ../config/watcher-mobymask-v2/mobymask-app.env:/app/.env
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh
- moby_data_server:/server
ports:
- "0.0.0.0:3002:3000"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3000"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s
shm_size: '1GB'

peer-test-app:
depends_on:
mobymask-watcher-server:
condition: service_healthy
image: cerc/react-peer:local
working_dir: /app/packages/test-app
command: ["sh", "-c", "yarn build && serve -s build"]
volumes:
- ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/config.json
ports:
- "0.0.0.0:3003:3000"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3000"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s

volumes:
mobymask_watcher_db_data:
moby_data_server:

networks:
# https://docs.docker.com/compose/networking/#configure-the-default-network
default:
# https://docs.docker.com/compose/networking/#use-a-pre-existing-network
name: mobymask-v2-network
external: true

1 change: 0 additions & 1 deletion app/data/config/watcher-mobymask-v2/.env

This file was deleted.

8 changes: 0 additions & 8 deletions app/data/config/watcher-mobymask-v2/config.json

This file was deleted.

8 changes: 8 additions & 0 deletions app/data/config/watcher-mobymask-v2/mobymask-app-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"relayNodes": [
"/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
],
"peer": {
"enableDebugInfo": true
}
}
9 changes: 9 additions & 0 deletions app/data/config/watcher-mobymask-v2/mobymask-app-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e

# Merging config files to get deployed contract address
jq -s '.[0] * .[1]' /app/src/mobymask-app-config.json /server/config.json > /app/src/config.json

npm run build

serve -s build
1 change: 1 addition & 0 deletions app/data/config/watcher-mobymask-v2/mobymask-app.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_WATCHER_URI=http://localhost:3001/graphql
5 changes: 5 additions & 0 deletions app/data/config/watcher-mobymask-v2/peer-id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "12D3KooWK6myjc8r1KBnfP9igp31qJkPaVfsKDjKrjoSefV5SDEo",
"privKey": "CAESQJMHbMaH+UEOtjGOzXYtoPO/cdHakCtN1hcnknIWzx/6ie1lxb+8kfzBjwt7apfj8fHlTCYSIVK8Q2AWu9a2h3g=",
"pubKey": "CAESIIntZcW/vJH8wY8Le2qX4/Hx5UwmEiFSvENgFrvWtod4"
}
10 changes: 10 additions & 0 deletions app/data/config/watcher-mobymask-v2/peer-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Private key of account with balance
PRIVATE_KEY=

# Assign deployed contract address from server config
CONTRACT_ADDRESS=`jq '.address' /server/config.json`

echo 'yarn peer-listener --contract-address <CONTRACT_ADDRESS> --private-key <PRIVATE_KEY>'
yarn peer-listener --contract-address $CONTRACT_ADDRESS --private-key $PRIVATE_KEY
1 change: 1 addition & 0 deletions app/data/config/watcher-mobymask-v2/peer.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RELAY="/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
5 changes: 5 additions & 0 deletions app/data/config/watcher-mobymask-v2/secrets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rpcUrl": "http://laconicd:8545",
"privateKey": "GENESIS_ACCOUNT_PRIVATE_KEY",
"baseURI": "http://127.0.0.1:3002/#"
}
8 changes: 8 additions & 0 deletions app/data/config/watcher-mobymask-v2/test-app-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"relayNodes": [
"/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
],
"peer": {
"enableDebugInfo": true
}
}
4 changes: 2 additions & 2 deletions app/data/config/watcher-mobymask-v2/watcher.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
enableDebugInfo = true

[server.p2p.peer]
relayMultiaddr = '/ip4/mobymask-watcher-server/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t'
relayMultiaddr = '/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t'
pubSubTopic = 'mobymask'
peerIdFile = './peer-id.json'
enableDebugInfo = true
Expand All @@ -55,7 +55,7 @@
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
rpcProviderEndpoint = "http://ipld-eth-server:8082"
rpcProviderEndpoint = "http://laconicd:8545"
blockDelayInMilliSecs = 60000

[upstream.cache]
Expand Down
4 changes: 3 additions & 1 deletion app/data/container-build/cerc-mobymask-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM node:18.15.0-alpine3.16

RUN apk --update --no-cache add make git
RUN apk --update --no-cache add make git jq

WORKDIR /app

COPY . .

RUN npm install -g serve

RUN echo "Building mobymask-ui" && \
npm install

Expand Down
13 changes: 13 additions & 0 deletions app/data/container-build/cerc-mobymask/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:16.17.1-alpine3.16

RUN apk --update --no-cache add python3 alpine-sdk

WORKDIR /app

COPY . .

RUN yarn

# Add scripts
RUN mkdir /scripts
ENV PATH="${PATH}:/scripts"
7 changes: 7 additions & 0 deletions app/data/container-build/cerc-mobymask/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/mobymask

# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

docker build -t cerc/mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/MobyMask
6 changes: 4 additions & 2 deletions app/data/container-build/cerc-react-peer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM node:18.15.0-alpine3.16

RUN apk --update --no-cache add make git
RUN apk --update --no-cache add make git python3

WORKDIR /app

COPY . .

RUN yarn global add serve

RUN echo "Building react-peer" && \
yarn && yarn workspace @cerc-io/react-peer build
yarn install --ignore-scripts && yarn build --ignore @cerc-io/test-app

WORKDIR /app
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt-get update \
&& apt-get install -y curl gnupg build-essential \
&& curl --silent --location https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs git \
&& apt-get install -y nodejs git busybox jq \
&& node -v

RUN corepack enable \
Expand Down
1 change: 1 addition & 0 deletions app/data/container-image-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cerc/uniswap-v3-info
cerc/watcher-mobymask-v2
cerc/react-peer
cerc/mobymask-ui
cerc/mobymask
cerc/test-container
cerc/eth-probe
cerc/builder-js
Expand Down
1 change: 1 addition & 0 deletions app/data/pod-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ watcher-erc20
watcher-erc721
watcher-uniswap-v3
watcher-mobymask-v2
mobymask-laconicd
test
eth-probe
keycloak
Expand Down
1 change: 1 addition & 0 deletions app/data/repository-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cerc-io/mobymask-watcher
cerc-io/watcher-ts
cerc-io/react-peer
cerc-io/mobymask-ui
cerc-io/MobyMask
vulcanize/uniswap-watcher-ts
vulcanize/uniswap-v3-info
vulcanize/assemblyscript
Expand Down
Loading