2023-04-18 12:55:58 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-03-24 11:53:54 +00:00
|
|
|
set -e
|
2023-04-05 11:56:38 +00:00
|
|
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2023-03-24 11:53:54 +00:00
|
|
|
|
2023-04-11 10:51:03 +00:00
|
|
|
CERC_CHAIN_ID="${CERC_CHAIN_ID:-${DEFAULT_CERC_CHAIN_ID}}"
|
|
|
|
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
|
|
|
|
CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
|
2023-05-05 08:02:19 +00:00
|
|
|
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
2023-09-06 09:18:32 +00:00
|
|
|
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
2023-04-11 10:51:03 +00:00
|
|
|
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
|
|
|
|
|
2023-04-12 12:47:13 +00:00
|
|
|
# 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"
|
|
|
|
|
2023-04-25 13:02:38 +00:00
|
|
|
if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then
|
|
|
|
# Use config from mounted volume (when running web-app along with watcher stack)
|
2023-04-12 12:47:13 +00:00
|
|
|
echo "Taking config for deployed contract from mounted volume"
|
2023-04-25 13:02:38 +00:00
|
|
|
while [ ! -f /server/config.json ]; do
|
|
|
|
echo "Config not found, retrying after 5 seconds"
|
|
|
|
sleep 5
|
|
|
|
done
|
2023-04-12 12:47:13 +00:00
|
|
|
|
|
|
|
# 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)
|
2023-04-06 09:47:00 +00:00
|
|
|
else
|
2023-04-12 12:47:13 +00:00
|
|
|
echo "Taking deployed contract details from env"
|
2023-04-06 09:47:00 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-31 05:11:26 +00:00
|
|
|
cd /app
|
|
|
|
git checkout $CERC_RELEASE
|
|
|
|
|
|
|
|
# Export config values in a json file
|
|
|
|
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
|
|
|
|
--argjson chainId "$CERC_CHAIN_ID" \
|
|
|
|
--argjson relayNodes "$CERC_RELAY_NODES" \
|
|
|
|
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
|
2023-09-06 09:18:32 +00:00
|
|
|
--arg pubsub "$CERC_PUBSUB" \
|
|
|
|
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub' \
|
2023-07-31 05:11:26 +00:00
|
|
|
/app/src/mobymask-app-config.json > /app/${CERC_CONFIG_FILE}
|
|
|
|
|
|
|
|
if [ "${CERC_USE_NPM}" = "true" ]; then
|
|
|
|
npm install
|
|
|
|
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" npm run build
|
|
|
|
else
|
|
|
|
yarn install
|
|
|
|
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" yarn build
|
|
|
|
fi
|
|
|
|
|
|
|
|
http-server -p 80 /app/build
|