From 39fc53656281aca239b339cd5cd02a51feeadb08 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 30 Nov 2023 15:39:07 +0530 Subject: [PATCH] Perform uniswap app deployment in the urbit container --- .../docker-compose-uniswap-interface.yml | 14 +--- .../data/compose/docker-compose-urbit.yml | 7 +- .../config/uniswap-interface/build-app.sh | 12 ++- .../uniswap-interface/deploy-to-urbit.sh | 5 +- .../uniswap-interface/deploy-uniswap-app.sh | 79 +++++++++++++++++++ .../run-urbit-ship.sh | 5 +- 6 files changed, 96 insertions(+), 26 deletions(-) create mode 100755 stack_orchestrator/data/config/uniswap-interface/deploy-uniswap-app.sh rename stack_orchestrator/data/config/{uniswap-interface => urbit}/run-urbit-ship.sh (79%) diff --git a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml index 429cf40c..b41bb865 100644 --- a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml +++ b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml @@ -8,16 +8,8 @@ services: - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY} command: ["./build-app.sh"] volumes: - - uniswap_build:/app/build + - app_builds:/app-builds - ../config/uniswap-interface/build-app.sh:/app/build-app.sh - ports: - - "3000" - healthcheck: - test: ["CMD", "nc", "-vz", "localhost", "3000"] - interval: 20s - timeout: 5s - retries: 15 - start_period: 5s uniswap-urbit-deployment: image: cerc/uniswap-urbit-deployment:local @@ -29,10 +21,10 @@ services: # - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY} command: ["./deploy-to-urbit.sh"] volumes: - - uniswap_build:/app/build + - app_builds:/app-builds - urbit_data:/urbit - ../config/uniswap-interface/deploy-to-urbit.sh:/app/deploy-to-urbit.sh volumes: - uniswap_build: + app_builds: urbit_data: diff --git a/stack_orchestrator/data/compose/docker-compose-urbit.yml b/stack_orchestrator/data/compose/docker-compose-urbit.yml index 067c7f3b..6b12e31c 100644 --- a/stack_orchestrator/data/compose/docker-compose-urbit.yml +++ b/stack_orchestrator/data/compose/docker-compose-urbit.yml @@ -4,10 +4,12 @@ services: urbit-fake-ship: restart: unless-stopped image: tloncorp/vere - entrypoint: ["bash", "-c", "./run-urbit-ship.sh"] + entrypoint: ["bash", "-c", "./run-urbit-ship.sh && deploy-uniswap-app.sh"] volumes: - urbit_data:/urbit - - ../config/uniswap-interface/run-urbit-ship.sh:/urbit/run-urbit-ship.sh + - app_builds:/app-builds + - ../config/urbit/run-urbit-ship.sh:/urbit/run-urbit-ship.sh + - ../config/uniswap-interface/deploy-uniswap-app.sh:/urbit/deploy-uniswap-app.sh ports: - "8080:80" - "12321:12321" @@ -20,3 +22,4 @@ services: volumes: urbit_data: + app_builds: diff --git a/stack_orchestrator/data/config/uniswap-interface/build-app.sh b/stack_orchestrator/data/config/uniswap-interface/build-app.sh index 7f8748b4..d3b012e6 100755 --- a/stack_orchestrator/data/config/uniswap-interface/build-app.sh +++ b/stack_orchestrator/data/config/uniswap-interface/build-app.sh @@ -6,15 +6,13 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then fi # Check and exit if a deployment already exists (on restarts) -if [ -f ./build ]; then - echo "build already exists, remove volume to rebuild" +if [ -d /app-builds/uniswap/build ]; then + echo "Build already exists, remove volume to rebuild" exit 0 fi yarn build -# Create symlink to host built files with correct URL path -# mkdir -p /app/urbit/apps -# ln -s /app/build /app/urbit/apps/uniswap - -# node_modules/.bin/serve urbit -s -l 3000 +# Move build to app-builds so urbit can deploy it +mkdir /app-builds/uniswap +cp -r ./build /app-builds/uniswap/ diff --git a/stack_orchestrator/data/config/uniswap-interface/deploy-to-urbit.sh b/stack_orchestrator/data/config/uniswap-interface/deploy-to-urbit.sh index 56ab2445..04ce5e7e 100755 --- a/stack_orchestrator/data/config/uniswap-interface/deploy-to-urbit.sh +++ b/stack_orchestrator/data/config/uniswap-interface/deploy-to-urbit.sh @@ -8,7 +8,4 @@ fi tail -f /dev/null # TODO: -# Take urbit endpoint from env -# Check if urbit endpoint is up -# Fire curl requests to create/mount a uniswap desk -# Copy over build to desk data dir +# Wait for glob to exist, copy it over and host it diff --git a/stack_orchestrator/data/config/uniswap-interface/deploy-uniswap-app.sh b/stack_orchestrator/data/config/uniswap-interface/deploy-uniswap-app.sh new file mode 100755 index 00000000..acbc755c --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/deploy-uniswap-app.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +uniswap_desk_dir='/urbit/zod/uniswap' + +dojo () { + curl -s --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' http://localhost:12321 +} + +hood () { + curl -s --data '{"source":{"dojo":"+hood/'"$1"'"},"sink":{"app":"hood"}}' http://localhost:12321 +} + +# Fire curl requests to create/mount a uniswap desk +curl -s --data '{"source":{"dojo":"+hood/merge %uniswap our %landscape"},"sink":{"app":"hood"}}' http://localhost:12321 +hood "mount %uniswap" + +tail -f /dev/null + + +# Wait for uniswap build to appear +# Copy over build to desk data dir + +# cat << EOF > file.txt +# :: +# :::: /hoon/map/mar +# :: Mark for js source maps +# /? 310 +# :: +# =, eyre +# |_ mud=@ +# ++ grow +# |% +# ++ mime [/application/octet-stream (as-octs:mimes:html (@t mud))] +# -- +# ++ grab +# |% :: convert from +# ++ mime |=([p=mite q=octs] (@t q.q)) +# ++ noun cord :: clam from %noun +# -- +# ++ grad %mime +# -- +# EOF + +# cp ~/zod/uniswap/mar/woff2.hoon ~/zod/uniswap/mar/woff.hoon and edit the only line that has woff2 to woff +# cp ~/zod/uniswap/mar/woff2.hoon ~/zod/uniswap/mar/ttf.hoon and edit woff2 to ttf + +# rm ~/zod/uniswap/desk.bill +# rm ~/zod/uniswap/desk.ship + +# |commit %uniswap + +# -landscape!make-glob %uniswap /build + +# Curl and wait for the glob to be hosted + +# From landscape CI: +# $1: the folder of files to glob +# $2: the location of the docket file +# hash=$(ls -1 -c zod/.urb/put | head -1 | sed "s/glob-\([a-z0-9\.]*\).glob/\1/") +# sed -i "s/glob\-[a-z0-9\.]*glob' *[a-z0-9\.]*\]/glob-$hash.glob' $hash]/g" $2 + +# :~ title+'Uniswap' +# info+'Self-hosted uniswap frontend.' +# color+0xcd.75df +# image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg' +# base+'uniswap' +# glob-http+['https://urbit-uniswap-laconic.nyc3.digitaloceanspaces.com/glob-0v3.5in3n.an2ft.c89g2.b6nu6.qek41.glob' 0v3.5in3n.an2ft.c89g2.b6nu6.qek41] +# version+[0 0 1] +# website+'https://uniswap.org/' +# license+'MIT' +# == + +# |commit %uniswap +# |install our %uniswap diff --git a/stack_orchestrator/data/config/uniswap-interface/run-urbit-ship.sh b/stack_orchestrator/data/config/urbit/run-urbit-ship.sh similarity index 79% rename from stack_orchestrator/data/config/uniswap-interface/run-urbit-ship.sh rename to stack_orchestrator/data/config/urbit/run-urbit-ship.sh index bb3445dd..bb301c81 100755 --- a/stack_orchestrator/data/config/uniswap-interface/run-urbit-ship.sh +++ b/stack_orchestrator/data/config/urbit/run-urbit-ship.sh @@ -7,11 +7,12 @@ fi pier_dir="/urbit/zod" +# Run urbit ship in daemon mode # Check if the directory exists if [ -d "$pier_dir" ]; then echo "Pier directory already exists, rebooting..." - urbit -t zod + urbit -d zod else echo "Creating a new fake ship..." - urbit -t -F zod + urbit -d -F zod fi