Part of https://www.notion.so/Create-stacks-for-mainnet-1f2a6b22d4728034be4be2c51decf94e Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Reviewed-on: #18 Co-authored-by: shreerang <shreerang@noreply.git.vdb.to> Co-committed-by: shreerang <shreerang@noreply.git.vdb.to>
391 lines
9.8 KiB
Markdown
391 lines
9.8 KiB
Markdown
# Update Deployments
|
|
|
|
Instructions to reset / update the deployments
|
|
|
|
## Login
|
|
|
|
* Log in as `dev` user on the deployments VM
|
|
|
|
* All the deployments are placed in the `/srv` directory:
|
|
|
|
```bash
|
|
cd /srv
|
|
```
|
|
|
|
## laconic-wallet-web
|
|
|
|
* Deployment dir: `/srv/wallet/laconic-wallet-web-deployment`
|
|
|
|
* If code has changed, fetch and build with updated source code:
|
|
|
|
```bash
|
|
# testnet-onboarding-app source
|
|
cd ~/cerc/laconic-wallet-web
|
|
|
|
# Pull latest changes
|
|
git pull
|
|
|
|
# Checkout to the latest tag (https://git.vdb.to/LaconicNetwork/laconic-wallet-web/tags)
|
|
git checkout <tag>
|
|
|
|
# Rebuild the containers
|
|
cd /srv/wallet
|
|
|
|
laconic-so --stack ~/cerc/laconic-wallet-web/stack/stack-orchestrator/stack/laconic-wallet-web build-containers --force-rebuild
|
|
```
|
|
|
|
* Update the configuration `laconic-wallet-web-deployment/config.env`:
|
|
|
|
```bash
|
|
# URL for the deploy app so that wallet can work with it
|
|
CERC_ALLOWED_URLS=https://deploy.laconic.com,https://store.laconic.com
|
|
|
|
# RPC URL for the mainnet node
|
|
CERC_LACONICD_RPC_URL="https://laconicd-mainnet.laconic.com"
|
|
```
|
|
|
|
* Restart the deployment:
|
|
|
|
```bash
|
|
laconic-so deployment --dir laconic-wallet-web-deployment stop
|
|
|
|
laconic-so deployment --dir laconic-wallet-web-deployment start
|
|
|
|
# Follow logs for laconic-wallet-web container, wait for the build to finish
|
|
laconic-so deployment --dir laconic-wallet-web-deployment logs laconic-wallet-web -f
|
|
```
|
|
|
|
* The web wallet can now be viewed at <https://wallet.laconic.com>
|
|
|
|
* Add `laconic-mainnet` network by clicking on `Add Network` and filling in required details
|
|
|
|
## laconic-console
|
|
|
|
* Deployment dir: `/srv/console/laconic-console-deployment`
|
|
|
|
* If code has changed, fetch and build with updated source code:
|
|
|
|
```bash
|
|
# testnet-onboarding-app source
|
|
cd ~/cerc/laconic-console
|
|
|
|
# Pull latest changes
|
|
git pull
|
|
|
|
# Checkout to the latest tag (https://git.vdb.to/cerc-io/laconic-console/tags)
|
|
git checkout <tag>
|
|
|
|
# Rebuild the containers
|
|
cd /srv/console
|
|
|
|
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console build-containers --force-rebuild
|
|
```
|
|
|
|
* Update the configuration, if required in `laconic-console-deployment/config.env`:
|
|
|
|
```bash
|
|
# Laconicd (hosted) GQL endpoint
|
|
LACONIC_HOSTED_ENDPOINT=https://laconicd-mainnet.laconic.com/graphql
|
|
```
|
|
|
|
* Restart the deployment:
|
|
|
|
```bash
|
|
laconic-so deployment --dir laconic-console-deployment stop
|
|
|
|
laconic-so deployment --dir laconic-console-deployment start
|
|
|
|
# Follow logs for console container
|
|
laconic-so deployment --dir laconic-console-deployment logs console -f
|
|
```
|
|
|
|
* The laconic console can now be viewed at <https://console-mainnet.laconic.com>
|
|
|
|
---
|
|
|
|
## Laconic Shopify
|
|
|
|
* Deployment dir: `/srv/shopify/laconic-shopify-deployment`
|
|
|
|
* If code has changed, fetch and build with updated source code:
|
|
|
|
```bash
|
|
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify setup-repositories --git-ssh --pull
|
|
|
|
# rebuild containers
|
|
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify build-containers --force-rebuild
|
|
```
|
|
|
|
* Update the configuration if required in `laconic-shopify-deployment/config.env`:
|
|
|
|
```bash
|
|
# laconicd RPC endpoint
|
|
CERC_LACONICD_RPC_ENDPOINT=https://laconicd-mainnet.laconic.com
|
|
|
|
# laconicd chain id
|
|
CERC_LACONICD_CHAIN_ID=laconic-mainnet
|
|
```
|
|
|
|
* Restart the deployment:
|
|
|
|
```bash
|
|
cd /srv/shopify
|
|
|
|
laconic-so deployment --dir laconic-shopify-deployment stop
|
|
|
|
laconic-so deployment --dir laconic-shopify-deployment start
|
|
```
|
|
|
|
## Webapp Deployer
|
|
|
|
* Fetch latest stack repos:
|
|
|
|
```bash
|
|
# In directory where webapp-deployer deployment was created
|
|
laconic-so --stack webapp-deployer-backend setup-repositories --pull
|
|
|
|
# Confirm latest commit hash in the ~/cerc/webapp-deployment-status-api repo
|
|
```
|
|
|
|
* Rebuild container images if there are any changes:
|
|
|
|
```bash
|
|
laconic-so --stack webapp-deployer-backend build-containers --force-rebuild
|
|
```
|
|
|
|
* Push stack images to the container registry:
|
|
|
|
* Login to the container registry:
|
|
|
|
```bash
|
|
# Set required variables
|
|
CONTAINER_REGISTRY_URL=container-registry.apps.vaasl.io
|
|
# For credentials: "cat /srv/service-provider/webapp-deployer/config.env | grep IMAGE_REGISTRY"
|
|
CONTAINER_REGISTRY_USERNAME=
|
|
CONTAINER_REGISTRY_PASSWORD=
|
|
|
|
# login to container registry
|
|
docker login $CONTAINER_REGISTRY_URL --username $CONTAINER_REGISTRY_USERNAME --password $CONTAINER_REGISTRY_PASSWORD
|
|
|
|
# WARNING! Using --password via the CLI is insecure. Use --password-stdin.
|
|
# WARNING! Your password will be stored unencrypted in /home/dev2/.docker/config.json.
|
|
# Configure a credential helper to remove this warning. See
|
|
# https://docs.docker.com/engine/reference/commandline/login/#credential-stores
|
|
|
|
# Login Succeeded
|
|
```
|
|
|
|
* Push images:
|
|
|
|
```bash
|
|
laconic-so deployment --dir webapp-deployer push-images
|
|
```
|
|
|
|
* Update deployer laconic registry config (`webapp-deployer/data/config/laconic.yml`) with new endpoints:
|
|
|
|
```bash
|
|
services:
|
|
registry:
|
|
rpcEndpoint: "https://laconicd-mainnet.laconic.com"
|
|
gqlEndpoint: "https://laconicd-mainnet.laconic.com/api"
|
|
userKey: "<userKey>"
|
|
bondId: "<bondId>"
|
|
chainId: laconic-mainnet
|
|
gasPrice: 0.001alnt
|
|
```
|
|
|
|
Note: Existing `userKey` and `bondId` can be used since they are carried over from SAPO testnet to mainnet
|
|
|
|
* Update any deployer config (`webapp-deployer/config.env`) if required
|
|
|
|
* Start the webapp deployer:
|
|
|
|
```bash
|
|
laconic-so deployment --dir webapp-deployer start
|
|
```
|
|
|
|
* Get the webapp-deployer pod id:
|
|
|
|
```bash
|
|
laconic-so deployment --dir webapp-deployer ps
|
|
|
|
# Expected output
|
|
# Running containers:
|
|
# id: default/laconic-096fed46af974a47-deployment-644db859c7-snbq6, name: laconic-096fed46af974a47-deployment-644db859c7-snbq6, ports: 10.42.2.11:9555->9555
|
|
|
|
# Set pod id
|
|
export POD_ID=
|
|
|
|
# Example:
|
|
# export POD_ID=laconic-096fed46af974a47-deployment-644db859c7-snbq6
|
|
```
|
|
|
|
* Copy over GPG keys files to the webapp-deployer container:
|
|
|
|
```bash
|
|
kubie ctx default
|
|
|
|
# Copy the GPG key files to the pod
|
|
kubectl cp <path-to-your-gpg-private-key> $POD_ID:/app
|
|
kubectl cp <path-to-your-gpg-public-key> $POD_ID:/app
|
|
|
|
# Required everytime you stop and start the deployer
|
|
```
|
|
|
|
* Check logs:
|
|
|
|
```bash
|
|
# Deployer
|
|
kubectl logs -f $POD_ID
|
|
|
|
# Deployer auction handler
|
|
kubectl logs -f $POD_ID -c cerc-webapp-auction-handler
|
|
```
|
|
|
|
* Update deployer UI config (`webapp-ui/config.env`):
|
|
|
|
```bash
|
|
# URL of the laconic console
|
|
LACONIC_HOSTED_CONFIG_app_console_link=https://console-mainnet.laconic.com
|
|
```
|
|
|
|
* Start the webapp UI:
|
|
|
|
```bash
|
|
laconic-so deployment --dir webapp-ui start
|
|
```
|
|
|
|
* Check logs
|
|
|
|
```bash
|
|
laconic-so deployment --dir webapp-ui logs webapp
|
|
```
|
|
|
|
## Deploy Backend
|
|
|
|
* Deployment dir: `/srv/deploy-backend/laconic-backend-deployment`
|
|
|
|
* If code has changed, fetch and build with updated source code:
|
|
|
|
```bash
|
|
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend setup-repositories --git-ssh --pull
|
|
|
|
# rebuild containers
|
|
laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend build-containers --force-rebuild
|
|
```
|
|
|
|
* Push updated images to the container registry:
|
|
|
|
```bash
|
|
cd /srv/deploy-backend
|
|
|
|
# login to container registry
|
|
CONTAINER_REGISTRY_URL=container-registry.apps.vaasl.io
|
|
# For credentials: "cat /srv/service-provider/webapp-deployer/config.env | grep IMAGE_REGISTRY"
|
|
CONTAINER_REGISTRY_USERNAME=
|
|
CONTAINER_REGISTRY_PASSWORD=
|
|
|
|
docker login $CONTAINER_REGISTRY_URL --username $CONTAINER_REGISTRY_USERNAME --password $CONTAINER_REGISTRY_PASSWORD
|
|
|
|
# Push backend images
|
|
laconic-so deployment --dir laconic-backend-deployment push-images
|
|
```
|
|
|
|
* Update the configuration if required in `laconic-backend-deployment/configmaps/config/prod.toml`:
|
|
|
|
```toml
|
|
...
|
|
[registryConfig]
|
|
fetchDeploymentRecordDelay = 5000
|
|
checkAuctionStatusDelay = 5000
|
|
restEndpoint = "https://laconicd-mainnet.laconic.com"
|
|
gqlEndpoint = "https://laconicd-mainnet.laconic.com/api"
|
|
chainId = "laconic-mainnet"
|
|
privateKey = "<private-key>"
|
|
bondId = "<bond-id>"
|
|
authority = "laconic-deploy"
|
|
[registryConfig.fee]
|
|
gasPrice = "0.001alnt"
|
|
...
|
|
```
|
|
|
|
* Restart the deployment:
|
|
|
|
```bash
|
|
laconic-so deployment --dir laconic-backend-deployment stop
|
|
|
|
laconic-so deployment --dir laconic-backend-deployment start
|
|
```
|
|
|
|
## Deploy Frontend
|
|
|
|
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>
|
|
|
|
### Prerequisites
|
|
|
|
* Node.js
|
|
|
|
* Yarn
|
|
|
|
### Setup
|
|
|
|
* On your local machine, clone the `snowballtools-base` repo:
|
|
|
|
```bash
|
|
git clone git@git.vdb.to:cerc-io/snowballtools-base.git
|
|
```
|
|
|
|
* Install dependencies:
|
|
|
|
```bash
|
|
cd snowballtools-base
|
|
yarn install
|
|
```
|
|
|
|
* In the deployer package, create required env:
|
|
|
|
```bash
|
|
cd packages/deployer
|
|
cp .env.example .env
|
|
```
|
|
|
|
Set the required variables:
|
|
|
|
```bash
|
|
REGISTRY_BOND_ID=<bond-id>
|
|
DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io
|
|
AUTHORITY=laconic-deploy
|
|
```
|
|
|
|
Note: The bond id should be set to the `laconic-deploy` authority
|
|
|
|
* Update required laconic config. You can use the same `userKey` and `bondId` used for deploying backend:
|
|
|
|
```bash
|
|
# Replace <user-pk> and <bond-id>
|
|
cat <<EOF > config.yml
|
|
services:
|
|
registry:
|
|
rpcEndpoint: https://laconicd-mainnet.laconic.com
|
|
gqlEndpoint: https://laconicd-mainnet.laconic.com/api
|
|
userKey: <user-pk>
|
|
bondId: <bond-id>
|
|
chainId: laconic-mainnet
|
|
gasPrice: 0.001alnt
|
|
EOF
|
|
```
|
|
|
|
Note: The `userKey` account should own the authority `laconic-deploy`
|
|
|
|
### Run
|
|
|
|
* Run frontend deployment script:
|
|
|
|
```bash
|
|
./deploy-frontend.sh
|
|
```
|
|
|
|
Follow deployment logs on the deployer UI
|
|
|
|
* On a successful deployment, the frontend can be viewed at <https://deploy.laconic.com>
|