Make remote Urbit app deployment scripts generic
This commit is contained in:
parent
096734f77b
commit
fbcebb3f92
@ -1,7 +1,12 @@
|
|||||||
version: '3.7'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# TODO: Describe usage
|
# 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:
|
urbit-fake-ship:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: tloncorp/vere
|
image: tloncorp/vere
|
||||||
|
@ -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"
|
@ -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"
|
|
@ -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"
|
@ -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"
|
|
Loading…
Reference in New Issue
Block a user