Refactor to make Urbit app deployment script generic
This commit is contained in:
parent
6bef0c5b2f
commit
07118a2d72
@ -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-builds/uniswap/mar
|
||||||
|
- ../config/uniswap-interface/urbit-files/desk.docket-0:/app-builds/uniswap/desk.docket-0
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
app_builds:
|
urbit_app_builds:
|
||||||
app_globs:
|
|
||||||
|
@ -5,15 +5,15 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: tloncorp/vere
|
image: tloncorp/vere
|
||||||
environment:
|
environment:
|
||||||
|
CERC_URBIT_APP: ${CERC_URBIT_APP}
|
||||||
CERC_IPFS_GLOB_HOST_ENDPOINT: ${CERC_IPFS_GLOB_HOST_ENDPOINT:-http://ipfs-glob-host:5001}
|
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}
|
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"]
|
entrypoint: ["bash", "-c", "./run-urbit-ship.sh && ./deploy-app.sh && tail -f /dev/null"]
|
||||||
volumes:
|
volumes:
|
||||||
- urbit_data:/urbit
|
- urbit_data:/urbit
|
||||||
- app_builds:/app-builds
|
- urbit_app_builds:/app-builds
|
||||||
- app_globs:/app-globs
|
|
||||||
- ../config/urbit/run-urbit-ship.sh:/urbit/run-urbit-ship.sh
|
- ../config/urbit/run-urbit-ship.sh:/urbit/run-urbit-ship.sh
|
||||||
- ../config/uniswap-interface/deploy-uniswap-app.sh:/urbit/deploy-uniswap-app.sh
|
- ../config/uniswap-interface/deploy-uniswap-app.sh:/urbit/deploy-app.sh
|
||||||
ports:
|
ports:
|
||||||
- "80"
|
- "80"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@ -40,7 +40,6 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
urbit_data:
|
urbit_data:
|
||||||
app_builds:
|
urbit_app_builds:
|
||||||
app_globs:
|
|
||||||
ipfs-import:
|
ipfs-import:
|
||||||
ipfs-data:
|
ipfs-data:
|
||||||
|
@ -14,5 +14,5 @@ fi
|
|||||||
yarn build
|
yarn build
|
||||||
|
|
||||||
# Move build to app-builds so urbit can deploy it
|
# Move build to app-builds so urbit can deploy it
|
||||||
mkdir /app-builds/uniswap
|
mkdir -p /app-builds/uniswap
|
||||||
cp -r ./build /app-builds/uniswap/
|
cp -r ./build /app-builds/uniswap/
|
||||||
|
@ -4,19 +4,39 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using IPFS endpoint ${CERC_IPFS_GLOB_HOST_ENDPOINT} for hosting globs"
|
if [ -z "$CERC_URBIT_APP" ]; then
|
||||||
echo "Using IPFS server endpoint ${CERC_IPFS_SERVER_ENDPOINT} for reading glob files"
|
echo "CERC_URBIT_APP not set, exiting"
|
||||||
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
|
exit 0
|
||||||
fi
|
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 the 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
|
# Fire curl requests to perform operations on the ship
|
||||||
dojo () {
|
dojo () {
|
||||||
curl -s --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' http://localhost:12321
|
curl -s --data '{"source":{"dojo":"'"$1"'"},"sink":{"stdout":null}}' http://localhost:12321
|
||||||
@ -26,80 +46,22 @@ hood () {
|
|||||||
curl -s --data '{"source":{"dojo":"+hood/'"$1"'"},"sink":{"app":"hood"}}' http://localhost:12321
|
curl -s --data '{"source":{"dojo":"+hood/'"$1"'"},"sink":{"app":"hood"}}' http://localhost:12321
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create/mount a uniswap desk
|
# Create / mount the app's desk
|
||||||
hood "merge %uniswap our %landscape"
|
hood "merge %${CERC_URBIT_APP} our %landscape"
|
||||||
hood "mount %uniswap"
|
hood "mount %${CERC_URBIT_APP}"
|
||||||
|
|
||||||
# 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
|
# Copy over build to desk data dir
|
||||||
cp -r ${uniswap_app_build} ${uniswap_desk_dir}
|
cp -r ${app_build} ${app_desk_dir}
|
||||||
|
|
||||||
# Create a mark file for .map file type
|
# Copy over the additional mark files
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/map.hoon"
|
cp ${app_mark_files}/* ${app_desk_dir}/mar/
|
||||||
::
|
|
||||||
:::: /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
|
rm "${app_desk_dir}/desk.bill"
|
||||||
cat << EOF > "${uniswap_desk_dir}/mar/woff.hoon"
|
rm "${app_desk_dir}/desk.ship"
|
||||||
|_ 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
|
# Commit changes and create a glob
|
||||||
hood "commit %uniswap"
|
hood "commit %${CERC_URBIT_APP}"
|
||||||
dojo "-landscape!make-glob %uniswap /build"
|
dojo "-landscape!make-glob %${CERC_URBIT_APP} /build"
|
||||||
|
|
||||||
glob_file=$(ls -1 -c zod/.urb/put | head -1)
|
glob_file=$(ls -1 -c zod/.urb/put | head -1)
|
||||||
echo "Created glob file: ${glob_file}"
|
echo "Created glob file: ${glob_file}"
|
||||||
@ -110,6 +72,9 @@ glob_cid=$(echo "$upload_response" | grep -o '"Hash":"[^"]*' | sed 's/"Hash":"//
|
|||||||
echo "Glob file uploaded to IFPS:"
|
echo "Glob file uploaded to IFPS:"
|
||||||
echo "{ cid: ${glob_cid}, filename: ${glob_file} }"
|
echo "{ cid: ${glob_cid}, filename: ${glob_file} }"
|
||||||
|
|
||||||
|
# Flag to skip installation
|
||||||
|
# Exit here if the installation not required
|
||||||
|
|
||||||
# Curl and wait for the glob to be hosted
|
# Curl and wait for the glob to be hosted
|
||||||
glob_url="${ipfs_server_endpoint}/ipfs/${glob_cid}?filename=${glob_file}"
|
glob_url="${ipfs_server_endpoint}/ipfs/${glob_cid}?filename=${glob_file}"
|
||||||
|
|
||||||
@ -128,19 +93,13 @@ done
|
|||||||
|
|
||||||
glob_hash=$(echo "$glob_file" | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
|
glob_hash=$(echo "$glob_file" | sed "s/glob-\([a-z0-9\.]*\).glob/\1/")
|
||||||
|
|
||||||
# Update the docket file
|
# Take the docket file from a volume (/app-builds/uniswap/desk.docket-0)
|
||||||
cat << EOF > "${uniswap_desk_dir}/desk.docket-0"
|
# Replace glob_url and glob_hash in that (refer landscape CI)
|
||||||
:~ title+'Uniswap'
|
|
||||||
info+'Self-hosted uniswap frontend.'
|
# Replace the docket file for app
|
||||||
color+0xcd.75df
|
# Substitue the glob URL and hash
|
||||||
image+'https://logowik.com/content/uploads/images/uniswap-uni7403.jpg'
|
cp ${app_docket_file} ${app_desk_dir}/
|
||||||
base+'uniswap'
|
sed -i "s|REPLACE_WITH_GLOB_URL|${glob_url}|g; s|REPLACE_WITH_GLOB_HASH|${glob_hash}|g" desk.docket-0
|
||||||
glob-http+['${glob_url}' ${glob_hash}]
|
|
||||||
version+[0 0 1]
|
|
||||||
website+'https://uniswap.org/'
|
|
||||||
license+'MIT'
|
|
||||||
==
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Commit changes and install the app
|
# Commit changes and install the app
|
||||||
hood "commit %uniswap"
|
hood "commit %uniswap"
|
||||||
|
@ -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
|
||||||
|
--
|
Loading…
Reference in New Issue
Block a user