Add MobyMask app service

This commit is contained in:
Prathamesh Musale 2023-10-02 15:57:32 +05:30
parent fab4358cd9
commit 3bb14a9cab
5 changed files with 56 additions and 19 deletions

View File

@ -15,18 +15,19 @@ services:
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
CERC_PUBSUB: ${CERC_PUBSUB}
CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS}
CERC_RELEASE: "laconic-v3"
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS}
CERC_SNAP_URL: ${CERC_SNAP_URL}
working_dir: /scripts
command: ["sh", "mobymask-app-start.sh"]
working_dir: /app
command: ["bash", "/scripts/mobymask-app-start.sh"]
volumes:
- ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
- peers_ids:/peers
- mobymask_deployment:/server
- nitro_deployment:/nitro
ports:
- "127.0.0.1:3004:80"
healthcheck:
@ -37,3 +38,8 @@ services:
start_period: 10s
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
peers_ids:
mobymask_deployment:
nitro_deployment:

View File

@ -11,21 +11,36 @@ CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
CERC_GOSSIPSUB_DIRECT_PEERS="${CERC_GOSSIPSUB_DIRECT_PEERS:-${DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS}}"
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
CERC_SNAP_URL="${CERC_SNAP_URL:-${DEFAULT_CERC_SNAP_URL}}"
# If not set (or []), check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then
echo "CERC_RELAY_NODES not provided, taking from the mounted volume"
CERC_RELAY_NODES="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]"
fi
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then
echo "CERC_DEPLOYED_CONTRACT not set"
exit 1
# Use config from mounted volume (when running web-app along with watcher stack)
echo "Taking config for deployed contract from mounted volume"
while [ ! -f /server/config.json ]; do
echo "Config not found, retrying in 5 seconds..."
sleep 5
done
# Get deployed contract address and chain id
CERC_DEPLOYED_CONTRACT=$(jq -r '.address' /server/config.json | tr -d '"')
CERC_CHAIN_ID=$(jq -r '.chainId' /server/config.json)
else
echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address"
fi
# Checkout to the required release/branch
cd /app
git checkout $CERC_RELEASE
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="/app/src/utils/nitro-addresses.json"
# Check if CERC_NA_ADDRESS is set
# Check if CERC_NA_ADDRESS environment variable is set
if [ -n "$CERC_NA_ADDRESS" ]; then
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
@ -38,24 +53,31 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
--arg vpa "$CERC_VPA_ADDRESS" \
--arg ca "$CERC_CA_ADDRESS" \
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
echo "$nitro_addresses_json" > /app/src/utils/nitro-addresses.json
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
elif [ -f ${nitro_addresses_file} ]; then
echo "Using Nitro addresses from ${nitro_addresses_file}:"
cat "$nitro_addresses_file"
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
else
echo "Nitro addresses not provided"
echo "Nitro addresses not available"
exit 1
fi
# Export config values in a json file
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
app_config_file="/app/src/utils/config.json"
app_config_json=$(jq -n \
--arg name "MobyMask" \
--argjson enableDebugInfo true \
--arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId "$CERC_CHAIN_ID" \
--argjson relayNodes "$CERC_RELAY_NODES" \
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
--arg pubsub "$CERC_PUBSUB" \
--argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers' \
/app/src/mobymask-app-config.json > /app/src/utils/config.json
yarn install
'.name = $name | .address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.enableDebugInfo = $enableDebugInfo | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers')
echo "$app_config_json" > "${app_config_file}"
REACT_APP_DEBUG_PEER=true \
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \
REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \
REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \

View File

@ -26,7 +26,13 @@ DEFAULT_CERC_ENABLE_PEER_L2_TXS=true
DEFAULT_CERC_DEPLOYED_CONTRACT=
# Chain ID is used by mobymask web-app for txs
DEFAULT_CERC_CHAIN_ID=42069
DEFAULT_CERC_CHAIN_ID=1212
# Watcher endpoint used by the web-app
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
# MobyMask snap URL to be used by the web-app
DEFAULT_CERC_SNAP_URL=http://localhost:8080
# Set of relay nodes to be used by web-apps
DEFAULT_CERC_RELAY_NODES=[]

View File

@ -61,7 +61,7 @@ elif [ -f ${nitro_addresses_file} ]; then
cat "$nitro_addresses_file"
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
else
echo "File ${nitro_addresses_file} not found"
echo "Nitro addresses not available"
exit 1
fi

View File

@ -16,6 +16,7 @@ repos:
- github.com/cerc-io/MobyMask@v0.1.3
# mobymask app repos
- github.com/cerc-io/mobymask-snap
- github.com/cerc-io/mobymask-ui@v0.2.0
containers:
# fixturenet images
- cerc/go-ethereum
@ -34,6 +35,7 @@ containers:
- cerc/mobymask
# mobymask app images
- cerc/mobymask-snap
- cerc/mobymask-ui
pods:
- fixturenet-eth
- ipld-eth-server
@ -43,3 +45,4 @@ pods:
- nitro-reverse-payment-proxy
- watcher-mobymask-v3
- mobymask-snap
- mobymask-app-v3