forked from cerc-io/stack-orchestrator
Add stack for running osmosis frontend app (#673)
* osmosis FE stack * chmod * dont use 3000 * fix for neww stack format * updates * update osmosis readme * Update stack.yml * Update osmosis frontend stack to serve app * Host osmosis app static build using python server * Fix mapped ports in deployment for containers * Update instructions * Use nginx server to host files and handle page reloads * Fix typo --------- Co-authored-by: zramsay <zach@bluecollarcoding.ca> Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
parent
f9eb5a4ba8
commit
fa6b570f4a
@ -3,7 +3,7 @@ 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:v0.24.0
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ipfs-import:/import
|
- ipfs-import:/import
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
version: "3.2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
osmosis-front-end:
|
||||||
|
image: cerc/osmosis-front-end:local
|
||||||
|
restart: on-failure
|
||||||
|
environment:
|
||||||
|
- NEXT_PUBLIC_WEB_API_BASE_URL=${CERC_WEB_API_BASE_URL}
|
||||||
|
working_dir: /app/packages/web
|
||||||
|
command: ["./build-app.sh"]
|
||||||
|
volumes:
|
||||||
|
- ../config/osmosis/build-app.sh:/app/packages/web/build-app.sh
|
||||||
|
- app_builds:/app-builds
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.23-alpine
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
osmosis-front-end:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
volumes:
|
||||||
|
- ../config/osmosis/nginx:/etc/nginx/conf.d
|
||||||
|
- app_builds:/usr/share/nginx
|
||||||
|
ports:
|
||||||
|
- "80"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "localhost", "80"]
|
||||||
|
interval: 20s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 15
|
||||||
|
start_period: 5s
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app_builds:
|
18
stack_orchestrator/data/config/osmosis/build-app.sh
Executable file
18
stack_orchestrator/data/config/osmosis/build-app.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and exit if a deployment already exists (on restarts)
|
||||||
|
if [ -d /app-builds/osmosis/build ]; then
|
||||||
|
echo "Build already exists, remove volume to rebuild"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
yarn build:static
|
||||||
|
|
||||||
|
# Move build to app-builds
|
||||||
|
mkdir -p /app-builds/osmosis
|
||||||
|
cp -r ./out /app-builds/osmosis/build
|
16
stack_orchestrator/data/config/osmosis/nginx/web-app.conf
Normal file
16
stack_orchestrator/data/config/osmosis/nginx/web-app.conf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/osmosis/build;
|
||||||
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
# First attempt to serve request as file, then as html,
|
||||||
|
# then as directory, then fall back to displaying a 404.
|
||||||
|
try_files $uri $uri.html $uri/ /index.html =404;
|
||||||
|
}
|
||||||
|
}
|
4
stack_orchestrator/data/container-build/cerc-osmosis-front-end/build.sh
Executable file
4
stack_orchestrator/data/container-build/cerc-osmosis-front-end/build.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build the osmosis front end image
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
docker build -t cerc/osmosis-front-end:local -f ${CERC_REPO_BASE_DIR}/osmosis-frontend/docker/Dockerfile.static ${build_command_args} ${CERC_REPO_BASE_DIR}/osmosis-frontend
|
141
stack_orchestrator/data/stacks/osmosis/README.md
Normal file
141
stack_orchestrator/data/stacks/osmosis/README.md
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
# self-hosted osmosis
|
||||||
|
|
||||||
|
Instructions to build and deploy:
|
||||||
|
- self-hosted gitea
|
||||||
|
- an ipfs node
|
||||||
|
- the osmosis front end
|
||||||
|
- a laconicd chain
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Clone required repositories:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack osmosis setup-repositories
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
|
||||||
|
```
|
||||||
|
# support image for the gitea package registry
|
||||||
|
laconic-so --stack build-support build-containers
|
||||||
|
|
||||||
|
laconic-so --stack osmosis 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:
|
||||||
|
```bash
|
||||||
|
laconic-so --stack osmosis deploy init --output osmosis-spec.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Ports
|
||||||
|
|
||||||
|
Edit `network` in spec file to map container ports to same ports in host
|
||||||
|
|
||||||
|
```
|
||||||
|
...
|
||||||
|
network:
|
||||||
|
ports:
|
||||||
|
proxy-server:
|
||||||
|
- '4000:4000'
|
||||||
|
nginx:
|
||||||
|
- '3000:80'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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:
|
||||||
|
```bash
|
||||||
|
laconic-so --stack osmosis deploy create --spec-file osmosis-spec.yml --deployment-dir osmosis-deployment
|
||||||
|
```
|
||||||
|
|
||||||
|
## Set env variables
|
||||||
|
|
||||||
|
Inside the deployment directory, open the file `config.env` and set the following env variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Osmosis API base URL
|
||||||
|
# Set this to proxy server endpoint for uniswap 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 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
|
||||||
|
```
|
||||||
|
|
||||||
|
## Start the stack
|
||||||
|
|
||||||
|
Start the deployment:
|
||||||
|
```bash
|
||||||
|
laconic-so deployment --dir osmosis-deployment start
|
||||||
|
```
|
||||||
|
|
||||||
|
* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy`
|
||||||
|
|
||||||
|
* The web app can be accessed at http://localhost:3000
|
||||||
|
|
||||||
|
## Laconic registry
|
||||||
|
|
||||||
|
Setup a test chain:
|
||||||
|
```
|
||||||
|
export CERC_NPM_REGISTRY_URL=https://git.vdb.to/api/packages/cerc-io/npm/
|
||||||
|
|
||||||
|
laconic-so --stack fixturenet-laconic-loaded setup-repositories --include git.vdb.to/cerc-io/laconicd,git.vdb.to/cerc-io/laconic-sdk,git.vdb.to/cerc-io/laconic-registry-cli,git.vdb.to/cerc-io/laconic-console
|
||||||
|
|
||||||
|
laconic-so --stack fixturenet-laconic-loaded build-containers
|
||||||
|
|
||||||
|
export LACONIC_HOSTED_ENDPOINT=http://<your-IP>
|
||||||
|
|
||||||
|
laconic-so --stack fixturenet-laconic-loaded deploy up
|
||||||
|
```
|
||||||
|
|
||||||
|
then `docker exec` into the `laconicd` container and either export the private key or create a new one and send funds to it. Use that private key for `LACONIC_HOTWALLET_KEY`.
|
||||||
|
|
||||||
|
## Clean up
|
||||||
|
|
||||||
|
To stop all osmosis services running in the background, while preserving data:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Only stop the docker containers
|
||||||
|
laconic-so deployment --dir osmosis-deployment stop
|
||||||
|
|
||||||
|
# Run 'start' to restart the deployment
|
||||||
|
```
|
||||||
|
|
||||||
|
To stop all osmosis services and also delete data:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Stop the docker containers
|
||||||
|
laconic-so deployment --dir osmosis-deployment stop --delete-volumes
|
||||||
|
|
||||||
|
# Remove deployment directory (deployment will have to be recreated for a re-run)
|
||||||
|
rm -r osmosis-deployment
|
||||||
|
```
|
||||||
|
|
||||||
|
To stop stack running Laconic registry
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack fixturenet-laconic-loaded deploy down
|
||||||
|
|
||||||
|
# Delete volumes
|
||||||
|
laconic-so --stack fixturenet-laconic-loaded deploy down --delete-volumes
|
||||||
|
```
|
30
stack_orchestrator/data/stacks/osmosis/stack.yml
Normal file
30
stack_orchestrator/data/stacks/osmosis/stack.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
version: "0.1"
|
||||||
|
name: osmosis
|
||||||
|
repos:
|
||||||
|
# For gitea
|
||||||
|
# - git.vdb.to/cerc-io/hosting@names-for-so
|
||||||
|
# - gitea.com/gitea/act_runner
|
||||||
|
# For osmosis frontend
|
||||||
|
- github.com/cerc-io/watcher-ts@v0.2.78
|
||||||
|
- github.com/cerc-io/osmosis-frontend@laconic
|
||||||
|
containers:
|
||||||
|
# - cerc/act-runner
|
||||||
|
# - cerc/act-runner-task-executor
|
||||||
|
- cerc/watcher-ts
|
||||||
|
- cerc/osmosis-front-end
|
||||||
|
pods:
|
||||||
|
- kubo
|
||||||
|
- proxy-server
|
||||||
|
- osmosis-front-end
|
||||||
|
# TODO: Fix pod config for deployment command
|
||||||
|
# TODO: mirroring all of osmosis repos: https://git.vdb.to/cerc-io/hosting/pulls/42
|
||||||
|
# - name: gitea
|
||||||
|
# repository: cerc-io/hosting
|
||||||
|
# path: gitea
|
||||||
|
# pre_start_command: "run-this-first.sh"
|
||||||
|
# post_start_command: "initialize-gitea.sh"
|
||||||
|
# - name: act-runner
|
||||||
|
# repository: cerc-io/hosting
|
||||||
|
# path: act-runner
|
||||||
|
# pre_start_command: "pre_start.sh"
|
||||||
|
# post_start_command: "post_start.sh"
|
@ -78,9 +78,9 @@ Inside the deployment directory, open the file `config.env` and set the followin
|
|||||||
|
|
||||||
# Uniswap API GQL Endpoint
|
# Uniswap API GQL Endpoint
|
||||||
# Set this to GQL proxy server endpoint for uniswap app
|
# Set this to GQL proxy server endpoint for uniswap app
|
||||||
# (Eg. http://localhost:4000/v1/graphql)
|
# (Eg. http://localhost:4000/v1/graphql - in case stack is being run locally with proxy enabled)
|
||||||
# (Eg. https://abc.xyz.com/v1/graphql)
|
# (Eg. https://abc.xyz.com/v1/graphql - in case https://abc.xyz.com is pointed to the proxy endpoint)
|
||||||
CERC_UNISWAP_GQL=
|
CERC_UNISWAP_GQL=http://localhost:4000/v1/graphql
|
||||||
|
|
||||||
# Optional
|
# Optional
|
||||||
|
|
||||||
@ -150,11 +150,18 @@ laconic-so deployment --dir uniswap-urbit-app-deployment start
|
|||||||
To stop all uniswap-urbit-app services running in the background, while preserving data:
|
To stop all uniswap-urbit-app services running in the background, while preserving data:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Only stop the docker containers
|
||||||
laconic-so deployment --dir uniswap-urbit-app-deployment stop
|
laconic-so deployment --dir uniswap-urbit-app-deployment stop
|
||||||
|
|
||||||
|
# Run 'start' to restart the deployment
|
||||||
```
|
```
|
||||||
|
|
||||||
To stop all uniswap-urbit-app services and also delete data:
|
To stop all uniswap-urbit-app services and also delete data:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Stop the docker containers
|
||||||
laconic-so deployment --dir uniswap-urbit-app-deployment stop --delete-volumes
|
laconic-so deployment --dir uniswap-urbit-app-deployment stop --delete-volumes
|
||||||
|
|
||||||
|
# Remove deployment directory (deployment will have to be recreated for a re-run)
|
||||||
|
rm -r uniswap-urbit-app-deployment
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user