Host glob files for uniswap

This commit is contained in:
Nabarun 2023-11-30 17:06:08 +05:30
parent 82bd927f3a
commit d80f81854a
8 changed files with 61 additions and 24 deletions

View File

@ -11,18 +11,23 @@ services:
- app_builds:/app-builds
- ../config/uniswap-interface/build-app.sh:/app/build-app.sh
uniswap-urbit-deployment:
image: cerc/uniswap-urbit-deployment:local
uniswap-glob-host:
image: cerc/urbit-globs-host:local
restart: unless-stopped
depends_on:
uniswap-interface:
condition: service_completed_successfully
# environment:
# - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY}
command: ["./deploy-to-urbit.sh"]
command: ["./host-uniswap-glob.sh"]
volumes:
- app_builds:/app-builds
- ../config/uniswap-interface/deploy-to-urbit.sh:/app/deploy-to-urbit.sh
- app_globs:/app-globs
- ../config/uniswap-interface/host-uniswap-glob.sh:/app/host-uniswap-glob.sh
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3000"]
interval: 20s
timeout: 5s
retries: 15
start_period: 10s
volumes:
app_builds:
app_globs:

View File

@ -8,6 +8,7 @@ services:
volumes:
- urbit_data:/urbit
- app_builds:/app-builds
- app_globs:/app-globs
- ../config/urbit/run-urbit-ship.sh:/urbit/run-urbit-ship.sh
- ../config/uniswap-interface/deploy-uniswap-app.sh:/urbit/deploy-uniswap-app.sh
ports:
@ -23,3 +24,4 @@ services:
volumes:
urbit_data:
app_builds:
app_globs:

View File

@ -1,11 +0,0 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
tail -f /dev/null
# TODO:
# Wait for glob to exist, copy it over and host it

View File

@ -97,11 +97,30 @@ rm "${uniswap_desk_dir}/desk.ship"
hood "commit %uniswap"
dojo "-landscape!make-glob %uniswap /build"
glob_file=$(ls -1 -c zod/.urb/put | head -1)
glob_hash=$($glob_file | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
echo "Copying over glob file to mounted volume"
mkdir -p /app-globs/uniswap
cp /urbit/zod/.urb/put/* /app-globs/uniswap/
glob_file=$(ls -1 -c zod/.urb/put | head -1)
echo "Glob filename: ${glob_file}"
glob_url="http://uniswap-glob-host:3000/${glob_file}"
# Curl and wait for the glob to be hosted
glob_url="http://uniswap-glob-host:3000/${glob_file}"
echo "Checking if glob file hosted at ${glob_url}"
while true; do
response=$(curl -sL -w "%{http_code}" -o /dev/null "$glob_url")
if [ $response -eq 200 ]; then
echo "File found at $glob_url"
break # Exit the loop if the file is found
else
echo "File not found. Retrying in a few seconds..."
sleep 5
fi
done
glob_hash=$($glob_file | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
# Update the docket file
cat << EOF > "${uniswap_desk_dir}/desk.docket-0"

View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
# Use config from mounted volume (when running web-app along with watcher stack)
echo "Waiting for uniswap app glob"
while [ ! -d /app-globs/uniswap ]; do
echo "Glob directory not found, retrying in 5 seconds..."
sleep 5
done
# Copy to a new globs directory
mkdir -p globs
cp -r /app-globs/uniswap/* ./globs
# Serve the glob file
cd globs
python3 -m http.server 3000 --bind 0.0.0.0

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
# Build the uniswap-urbit-deployment image
# Build the urbit-globs-host image
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/uniswap-urbit-deployment:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${SCRIPT_DIR}
docker build -t cerc/urbit-globs-host:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${SCRIPT_DIR}

View File

@ -6,7 +6,7 @@ repos:
- github.com/cerc-io/uniswap-interface@pm-urbit-hosting
containers:
- cerc/uniswap-interface
- cerc/uniswap-urbit-deployment
- cerc/urbit-globs-host
# TODO: Add container for urbit
pods:
- uniswap-interface