Refactor to make Urbit setup generic (#682)
* Refactor to make Urbit app deployment script generic * Rename urbit pod and update instructions * Add a flag to allow skipping app installation on Urbit * Make remote Urbit app deployment scripts generic * Move remote deployment scripts to urbit fixturenet * Update and use existing kubo pod for Urbit glob hosting
This commit is contained in:
parent
077ea80c70
commit
f9eb5a4ba8
@ -0,0 +1,36 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Runs an Urbit fake ship and attempts an app installation using given data
|
||||||
|
# Uploads the app glob to given IPFS endpoint
|
||||||
|
# From urbit_app_builds volume:
|
||||||
|
# - takes app build from ${CERC_URBIT_APP}/build (waits for it to appear)
|
||||||
|
# - takes additional mark files from ${CERC_URBIT_APP}/mar
|
||||||
|
# - takes the docket file from ${CERC_URBIT_APP}/desk.docket-0
|
||||||
|
urbit-fake-ship:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: tloncorp/vere
|
||||||
|
environment:
|
||||||
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
CERC_URBIT_APP: ${CERC_URBIT_APP}
|
||||||
|
CERC_ENABLE_APP_INSTALL: ${CERC_ENABLE_APP_INSTALL:-true}
|
||||||
|
CERC_IPFS_GLOB_HOST_ENDPOINT: ${CERC_IPFS_GLOB_HOST_ENDPOINT:-http://ipfs:5001}
|
||||||
|
CERC_IPFS_SERVER_ENDPOINT: ${CERC_IPFS_SERVER_ENDPOINT:-http://ipfs:8080}
|
||||||
|
entrypoint: ["bash", "-c", "./run-urbit-ship.sh && ./deploy-app.sh && tail -f /dev/null"]
|
||||||
|
volumes:
|
||||||
|
- urbit_data:/urbit
|
||||||
|
- urbit_app_builds:/app-builds
|
||||||
|
- ../config/urbit/run-urbit-ship.sh:/urbit/run-urbit-ship.sh
|
||||||
|
- ../config/urbit/deploy-app.sh:/urbit/deploy-app.sh
|
||||||
|
ports:
|
||||||
|
- "80"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-v", "localhost", "80"]
|
||||||
|
interval: 20s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 15
|
||||||
|
start_period: 10s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
urbit_data:
|
||||||
|
urbit_app_builds:
|
@ -1,13 +1,24 @@
|
|||||||
version: "3.2"
|
version: "3.2"
|
||||||
|
|
||||||
# See: https://docs.ipfs.tech/install/run-ipfs-inside-docker/#set-up
|
# See: https://docs.ipfs.tech/install/run-ipfs-inside-docker/#set-up
|
||||||
services:
|
services:
|
||||||
ipfs:
|
ipfs:
|
||||||
image: ipfs/kubo:master-2023-02-20-714a968
|
image: ipfs/kubo:master-2023-02-20-714a968
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./ipfs/import:/import
|
- ipfs-import:/import
|
||||||
- ./ipfs/data:/data/ipfs
|
- ipfs-data:/data/ipfs
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:8080:8080"
|
- "4001"
|
||||||
- "0.0.0.0:4001:4001"
|
- "8080"
|
||||||
- "0.0.0.0:5001:5001"
|
- "0.0.0.0:5001:5001"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-v", "localhost", "5001"]
|
||||||
|
interval: 20s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 15
|
||||||
|
start_period: 10s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
ipfs-import:
|
||||||
|
ipfs-data:
|
||||||
|
@ -6,7 +6,7 @@ services:
|
|||||||
restart: on-failure
|
restart: on-failure
|
||||||
working_dir: /app/packages/cli
|
working_dir: /app/packages/cli
|
||||||
environment:
|
environment:
|
||||||
ENABLE_PROXY: ${ENABLE_PROXY:-true}
|
ENABLE_PROXY: ${CERC_ENABLE_PROXY:-true}
|
||||||
PROXY_UPSTREAM: ${CERC_PROXY_UPSTREAM}
|
PROXY_UPSTREAM: ${CERC_PROXY_UPSTREAM}
|
||||||
PROXY_ORIGIN_HEADER: ${CERC_PROXY_ORIGIN_HEADER}
|
PROXY_ORIGIN_HEADER: ${CERC_PROXY_ORIGIN_HEADER}
|
||||||
command: ["sh", "-c", "./run.sh"]
|
command: ["sh", "-c", "./run.sh"]
|
||||||
|
@ -9,9 +9,10 @@ services:
|
|||||||
- REACT_APP_AWS_API_ENDPOINT=${CERC_UNISWAP_GQL}
|
- REACT_APP_AWS_API_ENDPOINT=${CERC_UNISWAP_GQL}
|
||||||
command: ["./build-app.sh"]
|
command: ["./build-app.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- app_builds:/app-builds
|
|
||||||
- ../config/uniswap-interface/build-app.sh:/app/build-app.sh
|
- ../config/uniswap-interface/build-app.sh:/app/build-app.sh
|
||||||
|
- urbit_app_builds:/app-builds
|
||||||
|
- ../config/uniswap-interface/urbit-files/mar:/app/mar
|
||||||
|
- ../config/uniswap-interface/urbit-files/desk.docket-0:/app/desk.docket-0
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
app_builds:
|
urbit_app_builds:
|
||||||
app_globs:
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
version: '3.7'
|
|
||||||
|
|
||||||
services:
|
|
||||||
urbit-fake-ship:
|
|
||||||
restart: unless-stopped
|
|
||||||
image: tloncorp/vere
|
|
||||||
environment:
|
|
||||||
CERC_IPFS_GLOB_HOST_ENDPOINT: ${CERC_IPFS_GLOB_HOST_ENDPOINT:-http://ipfs-glob-host:5001}
|
|
||||||
CERC_IPFS_SERVER_ENDPOINT: ${CERC_IPFS_SERVER_ENDPOINT:-http://ipfs-glob-host:8080}
|
|
||||||
entrypoint: ["bash", "-c", "./run-urbit-ship.sh && ./deploy-uniswap-app.sh && tail -f /dev/null"]
|
|
||||||
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:
|
|
||||||
- "80"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "nc", "-v", "localhost", "80"]
|
|
||||||
interval: 20s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 15
|
|
||||||
start_period: 10s
|
|
||||||
|
|
||||||
ipfs-glob-host:
|
|
||||||
image: ipfs/kubo:master-2023-02-20-714a968
|
|
||||||
volumes:
|
|
||||||
- ipfs-import:/import
|
|
||||||
- ipfs-data:/data/ipfs
|
|
||||||
ports:
|
|
||||||
- "8080"
|
|
||||||
- "5001"
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "nc", "-v", "localhost", "5001"]
|
|
||||||
interval: 20s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 15
|
|
||||||
start_period: 10s
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
urbit_data:
|
|
||||||
app_builds:
|
|
||||||
app_globs:
|
|
||||||
ipfs-import:
|
|
||||||
ipfs-data:
|
|
@ -13,6 +13,9 @@ fi
|
|||||||
|
|
||||||
yarn build
|
yarn build
|
||||||
|
|
||||||
# Move build to app-builds so urbit can deploy it
|
# Copy over build and other files to app-builds for urbit deployment
|
||||||
mkdir /app-builds/uniswap
|
mkdir -p /app-builds/uniswap
|
||||||
cp -r ./build /app-builds/uniswap/
|
cp -r ./build /app-builds/uniswap/
|
||||||
|
|
||||||
|
cp -r mar /app-builds/uniswap/
|
||||||
|
cp desk.docket-0 /app-builds/uniswap/
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Using IPFS endpoint ${CERC_IPFS_GLOB_HOST_ENDPOINT} for hosting globs"
|
|
||||||
echo "Using IPFS server endpoint ${CERC_IPFS_SERVER_ENDPOINT} for reading glob files"
|
|
||||||
ipfs_host_endpoint=${CERC_IPFS_GLOB_HOST_ENDPOINT}
|
|
||||||
ipfs_server_endpoint=${CERC_IPFS_SERVER_ENDPOINT}
|
|
||||||
|
|
||||||
uniswap_app_build='/app-builds/uniswap/build'
|
|
||||||
uniswap_desk_dir='/urbit/zod/uniswap'
|
|
||||||
|
|
||||||
if [ -d ${uniswap_desk_dir} ]; then
|
|
||||||
echo "Uniswap desk dir already exists, skipping deployment..."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fire curl requests to perform operations on the ship
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create/mount a uniswap desk
|
|
||||||
hood "merge %uniswap our %landscape"
|
|
||||||
hood "mount %uniswap"
|
|
||||||
|
|
||||||
# Loop until the uniswap build appears
|
|
||||||
while [ ! -d ${uniswap_app_build} ]; do
|
|
||||||
echo "Uniswap app build not found, retrying in 5s..."
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
echo "Build found..."
|
|
||||||
|
|
||||||
# Copy over build to desk data dir
|
|
||||||
cp -r ${uniswap_app_build} ${uniswap_desk_dir}
|
|
||||||
|
|
||||||
# Create a mark file for .map file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/map.hoon"
|
|
||||||
::
|
|
||||||
:::: /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
|
|
||||||
|
|
||||||
# Create a mark file for .woff file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/woff.hoon"
|
|
||||||
|_ dat=octs
|
|
||||||
++ grow
|
|
||||||
|%
|
|
||||||
++ mime [/font/woff dat]
|
|
||||||
--
|
|
||||||
++ grab
|
|
||||||
|%
|
|
||||||
++ mime |=([=mite =octs] octs)
|
|
||||||
++ noun octs
|
|
||||||
--
|
|
||||||
++ grad %mime
|
|
||||||
--
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create a mark file for .ttf file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/ttf.hoon"
|
|
||||||
|_ dat=octs
|
|
||||||
++ grow
|
|
||||||
|%
|
|
||||||
++ mime [/font/ttf dat]
|
|
||||||
--
|
|
||||||
++ grab
|
|
||||||
|%
|
|
||||||
++ mime |=([=mite =octs] octs)
|
|
||||||
++ noun octs
|
|
||||||
--
|
|
||||||
++ grad %mime
|
|
||||||
--
|
|
||||||
EOF
|
|
||||||
|
|
||||||
rm "${uniswap_desk_dir}/desk.bill"
|
|
||||||
rm "${uniswap_desk_dir}/desk.ship"
|
|
||||||
|
|
||||||
# Commit changes and create a glob
|
|
||||||
hood "commit %uniswap"
|
|
||||||
dojo "-landscape!make-glob %uniswap /build"
|
|
||||||
|
|
||||||
glob_file=$(ls -1 -c zod/.urb/put | head -1)
|
|
||||||
echo "Created glob file: ${glob_file}"
|
|
||||||
|
|
||||||
upload_response=$(curl -X POST -F file=@./zod/.urb/put/${glob_file} ${ipfs_host_endpoint}/api/v0/add)
|
|
||||||
glob_cid=$(echo "$upload_response" | grep -o '"Hash":"[^"]*' | sed 's/"Hash":"//')
|
|
||||||
|
|
||||||
echo "Glob file uploaded to IFPS:"
|
|
||||||
echo "{ cid: ${glob_cid}, filename: ${glob_file} }"
|
|
||||||
|
|
||||||
# Curl and wait for the glob to be hosted
|
|
||||||
glob_url="${ipfs_server_endpoint}/ipfs/${glob_cid}?filename=${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=$(echo "$glob_file" | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
|
|
||||||
|
|
||||||
# Update the docket file
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/desk.docket-0"
|
|
||||||
:~ title+'Uniswap'
|
|
||||||
info+'Self-hosted uniswap frontend.'
|
|
||||||
color+0xcd.75df
|
|
||||||
image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg'
|
|
||||||
base+'uniswap'
|
|
||||||
glob-http+['${glob_url}' ${glob_hash}]
|
|
||||||
version+[0 0 1]
|
|
||||||
website+'https://uniswap.org/'
|
|
||||||
license+'MIT'
|
|
||||||
==
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Commit changes and install the app
|
|
||||||
hood "commit %uniswap"
|
|
||||||
hood "install our %uniswap"
|
|
||||||
|
|
||||||
echo "Uniswap app installed"
|
|
@ -1,110 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# $1: Glob file URL (eg. https://xyz.com/glob-0vabcd.glob)
|
|
||||||
# $2: Glob file hash (eg. 0vabcd)
|
|
||||||
# $3: Urbit ship's pier dir (default: ./zod)
|
|
||||||
|
|
||||||
if [ "$#" -lt 2 ]; then
|
|
||||||
echo "Insufficient arguments"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
glob_url=$1
|
|
||||||
glob_hash=$2
|
|
||||||
echo "Using glob file from ${glob_url} with hash ${glob_hash}"
|
|
||||||
|
|
||||||
# Default pier dir: ./zod
|
|
||||||
# Default desk dir: ./zod/uniswap
|
|
||||||
pier_dir="${3:-./zod}"
|
|
||||||
uniswap_desk_dir="${pier_dir}/uniswap"
|
|
||||||
echo "Using ${uniswap_desk_dir} as the Uniswap desk dir path"
|
|
||||||
|
|
||||||
# Fire curl requests to perform operations on the ship
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create/mount a uniswap desk
|
|
||||||
hood "merge %uniswap our %landscape"
|
|
||||||
hood "mount %uniswap"
|
|
||||||
|
|
||||||
# Create a mark file for .map file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/map.hoon"
|
|
||||||
::
|
|
||||||
:::: /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
|
|
||||||
|
|
||||||
# Create a mark file for .woff file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/woff.hoon"
|
|
||||||
|_ dat=octs
|
|
||||||
++ grow
|
|
||||||
|%
|
|
||||||
++ mime [/font/woff dat]
|
|
||||||
--
|
|
||||||
++ grab
|
|
||||||
|%
|
|
||||||
++ mime |=([=mite =octs] octs)
|
|
||||||
++ noun octs
|
|
||||||
--
|
|
||||||
++ grad %mime
|
|
||||||
--
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Create a mark file for .ttf file type
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/ttf.hoon"
|
|
||||||
|_ dat=octs
|
|
||||||
++ grow
|
|
||||||
|%
|
|
||||||
++ mime [/font/ttf dat]
|
|
||||||
--
|
|
||||||
++ grab
|
|
||||||
|%
|
|
||||||
++ mime |=([=mite =octs] octs)
|
|
||||||
++ noun octs
|
|
||||||
--
|
|
||||||
++ grad %mime
|
|
||||||
--
|
|
||||||
EOF
|
|
||||||
|
|
||||||
rm "${uniswap_desk_dir}/desk.bill"
|
|
||||||
rm "${uniswap_desk_dir}/desk.ship"
|
|
||||||
|
|
||||||
# Update the docket file
|
|
||||||
cat << EOF > "${uniswap_desk_dir}/desk.docket-0"
|
|
||||||
:~ title+'Uniswap'
|
|
||||||
info+'Self-hosted uniswap frontend.'
|
|
||||||
color+0xcd.75df
|
|
||||||
image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg'
|
|
||||||
base+'uniswap'
|
|
||||||
glob-http+['${glob_url}' ${glob_hash}]
|
|
||||||
version+[0 0 1]
|
|
||||||
website+'https://uniswap.org/'
|
|
||||||
license+'MIT'
|
|
||||||
==
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Commit changes and install the app
|
|
||||||
hood "commit %uniswap"
|
|
||||||
hood "install our %uniswap"
|
|
||||||
|
|
||||||
echo "Uniswap app installed"
|
|
@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# $1: Remote user host
|
|
||||||
# $2: Remote Urbit ship's pier dir path (eg. /home/user/zod)
|
|
||||||
# $3: Glob file URL (eg. https://xyz.com/glob-0vabcd.glob)
|
|
||||||
# $4: Glob file hash (eg. 0vabcd)
|
|
||||||
|
|
||||||
if [ "$#" -ne 4 ]; then
|
|
||||||
echo "Incorrect number of arguments"
|
|
||||||
echo "Usage: $0 <username@remote_host> </path/to/remote/pier/folder> <glob_url> <glob_hash>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
remote_user_host="$1"
|
|
||||||
remote_pier_folder="$2"
|
|
||||||
glob_url="$3"
|
|
||||||
glob_hash="$4"
|
|
||||||
|
|
||||||
installation_script="./install-uniswap-app.sh"
|
|
||||||
|
|
||||||
ssh "$remote_user_host" "bash -s $glob_url $glob_hash $remote_pier_folder" < "$installation_script"
|
|
@ -0,0 +1,10 @@
|
|||||||
|
:~ title+'Uniswap'
|
||||||
|
info+'Self-hosted uniswap frontend.'
|
||||||
|
color+0xcd.75df
|
||||||
|
image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg'
|
||||||
|
base+'uniswap'
|
||||||
|
glob-http+['REPLACE_WITH_GLOB_URL' REPLACE_WITH_GLOB_HASH]
|
||||||
|
version+[0 0 1]
|
||||||
|
website+'https://uniswap.org/'
|
||||||
|
license+'MIT'
|
||||||
|
==
|
@ -0,0 +1,18 @@
|
|||||||
|
::
|
||||||
|
:::: /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
|
||||||
|
--
|
@ -0,0 +1,12 @@
|
|||||||
|
|_ dat=octs
|
||||||
|
++ grow
|
||||||
|
|%
|
||||||
|
++ mime [/font/ttf dat]
|
||||||
|
--
|
||||||
|
++ grab
|
||||||
|
|%
|
||||||
|
++ mime |=([=mite =octs] octs)
|
||||||
|
++ noun octs
|
||||||
|
--
|
||||||
|
++ grad %mime
|
||||||
|
--
|
@ -0,0 +1,12 @@
|
|||||||
|
|_ dat=octs
|
||||||
|
++ grow
|
||||||
|
|%
|
||||||
|
++ mime [/font/woff dat]
|
||||||
|
--
|
||||||
|
++ grab
|
||||||
|
|%
|
||||||
|
++ mime |=([=mite =octs] octs)
|
||||||
|
++ noun octs
|
||||||
|
--
|
||||||
|
++ grad %mime
|
||||||
|
--
|
34
stack_orchestrator/data/config/urbit/deploy-app-to-remote-urbit.sh
Executable file
34
stack_orchestrator/data/config/urbit/deploy-app-to-remote-urbit.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1: Remote user host
|
||||||
|
# $2: App name (eg. uniswap)
|
||||||
|
# $3: Assets dir path (local) for app (eg. /home/user/myapp/urbit-files)
|
||||||
|
# $4: Remote Urbit ship's pier dir path (eg. /home/user/zod)
|
||||||
|
# $5: Glob file URL (eg. https://xyz.com/glob-0vabcd.glob)
|
||||||
|
# $6: Glob file hash (eg. 0vabcd)
|
||||||
|
|
||||||
|
if [ "$#" -ne 6 ]; then
|
||||||
|
echo "Incorrect number of arguments"
|
||||||
|
echo "Usage: $0 <username@remote_host> <app_name> </path/to/app/assets/folder> </path/to/remote/pier/folder> <glob_url> <glob_hash>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
remote_user_host="$1"
|
||||||
|
app_name=$2
|
||||||
|
app_assets_folder=$3
|
||||||
|
remote_pier_folder="$4"
|
||||||
|
glob_url="$5"
|
||||||
|
glob_hash="$6"
|
||||||
|
|
||||||
|
installation_script="./install-urbit-app.sh"
|
||||||
|
|
||||||
|
# Copy over the assets to remote machine in a tmp dir
|
||||||
|
remote_app_assets_folder=/tmp/urbit-app-assets/$app_name
|
||||||
|
ssh "$remote_user_host" "mkdir -p $remote_app_assets_folder"
|
||||||
|
scp -r $app_assets_folder/* $remote_user_host:$remote_app_assets_folder
|
||||||
|
|
||||||
|
# Run the installation script
|
||||||
|
ssh "$remote_user_host" "bash -s $app_name $remote_app_assets_folder '${glob_url}' $glob_hash $remote_pier_folder" < "$installation_script"
|
||||||
|
|
||||||
|
# Remove the tmp assets dir
|
||||||
|
ssh "$remote_user_host" "rm -rf $remote_app_assets_folder"
|
110
stack_orchestrator/data/config/urbit/deploy-app.sh
Executable file
110
stack_orchestrator/data/config/urbit/deploy-app.sh
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$CERC_URBIT_APP" ]; then
|
||||||
|
echo "CERC_URBIT_APP not set, exiting"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating Urbit application for ${CERC_URBIT_APP}"
|
||||||
|
|
||||||
|
app_desk_dir=/urbit/zod/${CERC_URBIT_APP}
|
||||||
|
if [ -d ${app_desk_dir} ]; then
|
||||||
|
echo "Desk dir already exists for ${CERC_URBIT_APP}, skipping deployment..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
app_build=/app-builds/${CERC_URBIT_APP}/build
|
||||||
|
app_mark_files=/app-builds/${CERC_URBIT_APP}/mar
|
||||||
|
app_docket_file=/app-builds/${CERC_URBIT_APP}/desk.docket-0
|
||||||
|
|
||||||
|
echo "Reading app build from ${app_build}"
|
||||||
|
echo "Reading additional mark files from ${app_mark_files}"
|
||||||
|
echo "Reading docket file ${app_docket_file}"
|
||||||
|
|
||||||
|
# Loop until the app's build appears
|
||||||
|
while [ ! -d ${app_build} ]; do
|
||||||
|
echo "${CERC_URBIT_APP} app build not found, retrying in 5s..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
echo "Build found..."
|
||||||
|
|
||||||
|
echo "Using IPFS endpoint ${CERC_IPFS_GLOB_HOST_ENDPOINT} for hosting the ${CERC_URBIT_APP} glob"
|
||||||
|
echo "Using IPFS server endpoint ${CERC_IPFS_SERVER_ENDPOINT} for reading ${CERC_URBIT_APP} glob"
|
||||||
|
ipfs_host_endpoint=${CERC_IPFS_GLOB_HOST_ENDPOINT}
|
||||||
|
ipfs_server_endpoint=${CERC_IPFS_SERVER_ENDPOINT}
|
||||||
|
|
||||||
|
# Fire curl requests to perform operations on the ship
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create / mount the app's desk
|
||||||
|
hood "merge %${CERC_URBIT_APP} our %landscape"
|
||||||
|
hood "mount %${CERC_URBIT_APP}"
|
||||||
|
|
||||||
|
# Copy over build to desk data dir
|
||||||
|
cp -r ${app_build} ${app_desk_dir}
|
||||||
|
|
||||||
|
# Copy over the additional mark files
|
||||||
|
cp ${app_mark_files}/* ${app_desk_dir}/mar/
|
||||||
|
|
||||||
|
rm "${app_desk_dir}/desk.bill"
|
||||||
|
rm "${app_desk_dir}/desk.ship"
|
||||||
|
|
||||||
|
# Commit changes and create a glob
|
||||||
|
hood "commit %${CERC_URBIT_APP}"
|
||||||
|
dojo "-landscape!make-glob %${CERC_URBIT_APP} /build"
|
||||||
|
|
||||||
|
glob_file=$(ls -1 -c zod/.urb/put | head -1)
|
||||||
|
echo "Created glob file: ${glob_file}"
|
||||||
|
|
||||||
|
# Upload the glob file to IPFS
|
||||||
|
echo "Uploading glob file to ${ipfs_host_endpoint}"
|
||||||
|
upload_response=$(curl -X POST -F file=@./zod/.urb/put/${glob_file} ${ipfs_host_endpoint}/api/v0/add)
|
||||||
|
glob_cid=$(echo "$upload_response" | grep -o '"Hash":"[^"]*' | sed 's/"Hash":"//')
|
||||||
|
|
||||||
|
glob_url="${ipfs_server_endpoint}/ipfs/${glob_cid}?filename=${glob_file}"
|
||||||
|
glob_hash=$(echo "$glob_file" | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
|
||||||
|
|
||||||
|
echo "Glob file uploaded to IFPS:"
|
||||||
|
echo "{ cid: ${glob_cid}, filename: ${glob_file} }"
|
||||||
|
echo "{ url: ${glob_url}, hash: ${glob_hash} }"
|
||||||
|
|
||||||
|
# Exit if the installation not required
|
||||||
|
if [ "$CERC_ENABLE_APP_INSTALL" = "false" ]; then
|
||||||
|
echo "CERC_ENABLE_APP_INSTALL set to false, skipping app installation"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Curl and wait for the glob to be hosted
|
||||||
|
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 5s..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Replace the docket file for app
|
||||||
|
# Substitue the glob URL and hash
|
||||||
|
cp ${app_docket_file} ${app_desk_dir}/
|
||||||
|
sed -i "s|REPLACE_WITH_GLOB_URL|${glob_url}|g; s|REPLACE_WITH_GLOB_HASH|${glob_hash}|g" ${app_desk_dir}/desk.docket-0
|
||||||
|
|
||||||
|
# Commit changes and install the app
|
||||||
|
hood "commit %${CERC_URBIT_APP}"
|
||||||
|
hood "install our %${CERC_URBIT_APP}"
|
||||||
|
|
||||||
|
echo "${CERC_URBIT_APP} app installed"
|
60
stack_orchestrator/data/config/urbit/install-urbit-app.sh
Executable file
60
stack_orchestrator/data/config/urbit/install-urbit-app.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1: App name (eg. uniswap)
|
||||||
|
# $2: Assets dir path (local) for app (eg. /home/user/myapp/urbit-files)
|
||||||
|
# $3: Glob file URL (eg. https://xyz.com/glob-0vabcd.glob)
|
||||||
|
# $4: Glob file hash (eg. 0vabcd)
|
||||||
|
# $5: Urbit ship's pier dir (default: ./zod)
|
||||||
|
|
||||||
|
if [ "$#" -lt 4 ]; then
|
||||||
|
echo "Insufficient arguments"
|
||||||
|
echo "Usage: $0 <app_name> </path/to/app/assets/folder> <glob_url> <glob_hash> [/path/to/remote/pier/folder]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
app_name=$1
|
||||||
|
app_mark_files=$2/mar
|
||||||
|
app_docket_file=$2/desk.docket-0
|
||||||
|
echo "Creating Urbit application for ${app_name}"
|
||||||
|
echo "Reading additional mark files from ${app_mark_files}"
|
||||||
|
echo "Reading docket file ${app_docket_file}"
|
||||||
|
|
||||||
|
glob_url=$3
|
||||||
|
glob_hash=$4
|
||||||
|
echo "Using glob file from ${glob_url} with hash ${glob_hash}"
|
||||||
|
|
||||||
|
# Default pier dir: ./zod
|
||||||
|
# Default desk dir: ./zod/<app_name>
|
||||||
|
pier_dir="${5:-./zod}"
|
||||||
|
app_desk_dir="${pier_dir}/${app_name}"
|
||||||
|
echo "Using ${app_desk_dir} as the ${app_name} desk dir path"
|
||||||
|
|
||||||
|
# Fire curl requests to perform operations on the ship
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create / mount the app's desk
|
||||||
|
hood "merge %${app_name} our %landscape"
|
||||||
|
hood "mount %${app_name}"
|
||||||
|
|
||||||
|
# Copy over the additional mark files
|
||||||
|
cp ${app_mark_files}/* ${app_desk_dir}/mar/
|
||||||
|
|
||||||
|
rm "${app_desk_dir}/desk.bill"
|
||||||
|
rm "${app_desk_dir}/desk.ship"
|
||||||
|
|
||||||
|
# Replace the docket file for app
|
||||||
|
# Substitue the glob URL and hash
|
||||||
|
cp ${app_docket_file} ${app_desk_dir}/
|
||||||
|
sed -i "s|REPLACE_WITH_GLOB_URL|${glob_url}|g; s|REPLACE_WITH_GLOB_HASH|${glob_hash}|g" ${app_desk_dir}/desk.docket-0
|
||||||
|
|
||||||
|
# Commit changes and install the app
|
||||||
|
hood "commit %${app_name}"
|
||||||
|
hood "install our %${app_name}"
|
||||||
|
|
||||||
|
echo "${app_name} app installed"
|
@ -7,11 +7,13 @@ fi
|
|||||||
|
|
||||||
pier_dir="/urbit/zod"
|
pier_dir="/urbit/zod"
|
||||||
|
|
||||||
|
# TODO: Bootstrap fake ship on the first run
|
||||||
|
|
||||||
# Run urbit ship in daemon mode
|
# Run urbit ship in daemon mode
|
||||||
# Check if the directory exists
|
# Check if the directory exists
|
||||||
if [ -d "$pier_dir" ]; then
|
if [ -d "$pier_dir" ]; then
|
||||||
echo "Pier directory already exists, rebooting..."
|
echo "Pier directory already exists, rebooting..."
|
||||||
urbit -d zod
|
/urbit/zod/.run -d
|
||||||
else
|
else
|
||||||
echo "Creating a new fake ship..."
|
echo "Creating a new fake ship..."
|
||||||
urbit -d -F zod
|
urbit -d -F zod
|
||||||
|
@ -47,7 +47,7 @@ laconic-so --stack proxy-server build-containers
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Whether to run the proxy server (Optional) (Default: true)
|
# Whether to run the proxy server (Optional) (Default: true)
|
||||||
ENABLE_PROXY=
|
CERC_ENABLE_PROXY=
|
||||||
|
|
||||||
# Upstream endpoint
|
# Upstream endpoint
|
||||||
# (Eg. https://api.example.org)
|
# (Eg. https://api.example.org)
|
||||||
|
@ -33,7 +33,7 @@ laconic-so --stack uniswap-urbit-app deploy init --output uniswap-urbit-app-spec
|
|||||||
|
|
||||||
### Ports
|
### Ports
|
||||||
|
|
||||||
Edit `network` in spec file to map container ports to same ports in host
|
Edit `network` in spec file to map container ports to same ports in host:
|
||||||
|
|
||||||
```
|
```
|
||||||
...
|
...
|
||||||
@ -43,12 +43,14 @@ network:
|
|||||||
- '8080:80'
|
- '8080:80'
|
||||||
proxy-server:
|
proxy-server:
|
||||||
- '4000:4000'
|
- '4000:4000'
|
||||||
ipfs-glob-host:
|
ipfs:
|
||||||
- '8081:8080'
|
- '8081:8080'
|
||||||
- '5001:5001'
|
- '5001:5001'
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: Skip the `ipfs` ports if need to use an externally running IPFS node
|
||||||
|
|
||||||
### Data volumes
|
### Data volumes
|
||||||
|
|
||||||
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
Container data volumes are bind-mounted to specified paths in the host filesystem.
|
||||||
@ -67,6 +69,9 @@ laconic-so --stack uniswap-urbit-app deploy create --spec-file uniswap-urbit-app
|
|||||||
Inside the deployment directory, open the file `config.env` and set the following env variables:
|
Inside the deployment directory, open the file `config.env` and set the following env variables:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# App to be installed (Do not change)
|
||||||
|
CERC_URBIT_APP=uniswap
|
||||||
|
|
||||||
# External RPC endpoints
|
# External RPC endpoints
|
||||||
# https://docs.infura.io/getting-started#2-create-an-api-key
|
# https://docs.infura.io/getting-started#2-create-an-api-key
|
||||||
CERC_INFURA_KEY=
|
CERC_INFURA_KEY=
|
||||||
@ -79,9 +84,13 @@ Inside the deployment directory, open the file `config.env` and set the followin
|
|||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
|
|
||||||
|
# Whether to enable app installation on Urbit
|
||||||
|
# (just builds and uploads the glob file if disabled) (Default: true)
|
||||||
|
CERC_ENABLE_APP_INSTALL=
|
||||||
|
|
||||||
# Whether to run the proxy GQL server
|
# Whether to run the proxy GQL server
|
||||||
# (Disable only if proxy not required to be run) (Default: true)
|
# (disable only if proxy not required to be run) (Default: true)
|
||||||
ENABLE_PROXY=
|
CERC_ENABLE_PROXY=
|
||||||
|
|
||||||
# Proxy server configuration
|
# Proxy server configuration
|
||||||
# Used only if proxy is enabled
|
# Used only if proxy is enabled
|
||||||
@ -97,11 +106,11 @@ Inside the deployment directory, open the file `config.env` and set the followin
|
|||||||
# IPFS configuration
|
# IPFS configuration
|
||||||
|
|
||||||
# IFPS endpoint to host the glob file on
|
# IFPS endpoint to host the glob file on
|
||||||
# (Default: http://ipfs-glob-host:5001 pointing to in-stack IPFS node)
|
# (Default: http://ipfs:5001 pointing to in-stack IPFS node)
|
||||||
CERC_IPFS_GLOB_HOST_ENDPOINT=
|
CERC_IPFS_GLOB_HOST_ENDPOINT=
|
||||||
|
|
||||||
# IFPS endpoint to fetch the glob file from
|
# IFPS endpoint to fetch the glob file from
|
||||||
# (Default: http://ipfs-glob-host:8080 pointing to in-stack IPFS node)
|
# (Default: http://ipfs:8080 pointing to in-stack IPFS node)
|
||||||
CERC_IPFS_SERVER_ENDPOINT=
|
CERC_IPFS_SERVER_ENDPOINT=
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,4 +10,5 @@ containers:
|
|||||||
pods:
|
pods:
|
||||||
- uniswap-interface
|
- uniswap-interface
|
||||||
- proxy-server
|
- proxy-server
|
||||||
- uniswap-urbit
|
- fixturenet-urbit
|
||||||
|
- kubo
|
||||||
|
Loading…
Reference in New Issue
Block a user