stack-orchestrator/stack_orchestrator/data/stacks/osmosis-urbit-app
prathamesh0 b9b758bfdd
Add a stack for running Osmosis frontend app on Urbit (#683)
* Deploy osmosis on Urbit fake ship

* Remove Urbit configuration from existing osmosis stack

* Add a separate stack for Osmosis front end on Urbit

* Run script for renaming build files with bash

* Add environment variables required in urbit osmosis build

* Fix BASEPATH in compose file

* Remove ipfs-glob-host from network config in osmosis readme

* Use laconic branch for osmosis frontend

---------

Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
2023-12-14 17:28:10 +05:30
..
README.md Add a stack for running Osmosis frontend app on Urbit (#683) 2023-12-14 17:28:10 +05:30
stack.yml Add a stack for running Osmosis frontend app on Urbit (#683) 2023-12-14 17:28:10 +05:30

Self-hosted Osmosis Front End On Urbit

Instructions to build and deploy:

  • Urbit
  • An ipfs node
  • The osmosis front end

Setup

Clone required repositories:

laconic-so --stack osmosis-urbit-app setup-repositories --pull

# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories and re-run the command

Build the container images:

laconic-so --stack osmosis-urbit-app build-containers

Create a deployment

First, create a spec file for the deployment, which will map the stack's ports and volumes to the host:

laconic-so --stack osmosis-urbit-app deploy init --output osmosis-urbit-app-spec.yml

Ports

Edit network in spec file to map container ports to same ports in host:

...
network:
  ports:
    urbit-fake-ship:
      - '8080:80'
    proxy-server:
      - '4000:4000'
    ipfs:
      - '8081:8080'
      - '5001:5001'

Note: Skip the ipfs ports if need to use an externally running IPFS node

Data volumes

Container data volumes are bind-mounted to specified paths in the host filesystem. The default setup (generated by laconic-so deploy init) places the volumes in the ./data subdirectory of the deployment directory. The default mappings can be customized by editing the "spec" file generated by laconic-so deploy init.


Once you've made any needed changes to the spec file, create a deployment from it:

laconic-so --stack osmosis-urbit-app deploy create --spec-file osmosis-urbit-app-spec.yml --deployment-dir osmosis-urbit-app-deployment

Set env variables

Inside the deployment directory, open the file config.env and set the following env variables:

(Note: Use the following config as is if running the stack locally)

# App to be installed (Do not change)
CERC_URBIT_APP=osmosis

# Osmosis API base URL
# Set this to proxy server endpoint for osmosis app
# (Eg. http://localhost:4000 - in case stack is being run locally with proxy enabled)
# (Eg. https://abc.xyz.com - in case https://abc.xyz.com is pointed to the proxy endpoint)
CERC_WEB_API_BASE_URL=http://localhost:4000

# 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 server
# (Disable only if proxy not required to be run) (Default: true)
CERC_ENABLE_PROXY=

# Proxy server configuration
# Used only if proxy is enabled

# Upstream API URL
CERC_PROXY_UPSTREAM=https://app.osmosis.zone

# IPFS configuration

# IFPS endpoint to host the glob file on
# (Default: http://ipfs:5001 pointing to in-stack IPFS node)
CERC_IPFS_GLOB_HOST_ENDPOINT=

# IFPS endpoint to fetch the glob file from
# (Default: http://ipfs:8080 pointing to in-stack IPFS node)
CERC_IPFS_SERVER_ENDPOINT=

Start the stack

Start the deployment:

laconic-so deployment --dir osmosis-urbit-app-deployment start
  • List and check the health status of all the containers using docker ps and wait for them to be healthy

  • Run the following to get login password for Urbit web interface:

    laconic-so deployment --dir osmosis-urbit-app-deployment exec urbit-fake-ship "curl -s --data '{\"source\":{\"dojo\":\"+code\"},\"sink\":{\"stdout\":null}}' http://localhost:12321"
    
    # Expected output: "<PASSWORD>\n"%
    
  • Open the Urbit web UI at http://localhost:8080 and use the PASSWORD from previous step to login

  • The osmosis app is not available when starting stack for the first time. Check urbit-fake-ship logs to see that app has installed:

    laconic-so deployment --dir osmosis-urbit-app-deployment logs -f
    
    # Expected output:
    # laconic-3ccf7ee79bdae874-urbit-fake-ship-1    | docket: fetching %http glob for %osmosis desk
    # laconic-3ccf7ee79bdae874-urbit-fake-ship-1    | ">="">="osmosis app installed
    
  • The osmosis app will be now visible at http://localhost:8080

Clean up

To stop all osmosis-urbit-app services running in the background, while preserving data:

# Only stop the docker containers
laconic-so deployment --dir osmosis-urbit-app-deployment stop

# Run 'start' to restart the deployment

To stop all osmosis-urbit-app services and also delete data:

# Stop the docker containers
laconic-so deployment --dir osmosis-urbit-app-deployment stop --delete-volumes

# Remove deployment directory (deployment will have to be recreated for a re-run)
rm -r osmosis-urbit-app-deployment