laconicd-stack/docs/update-deployments.md
2025-06-19 11:01:34 +05:30

395 lines
9.5 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
# Fetch from remote
git fetch
# 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
```
* 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>
## laconic-console
* Deployment dir: `/srv/console/laconic-console-testnet2-deployment`
* Set deployment directory in a variable:
```bash
CONSOLE_DEPLOYMENT=/srv/console/laconic-console-testnet2-deployment
```
* Update the configuration:
```bash
nano $CONSOLE_DEPLOYMENT/config.env
```
```bash
# Laconicd (hosted) GQL endpoint
LACONIC_HOSTED_ENDPOINT=https://laconicd-mainnet.laconic.com
# laconicd chain id
CERC_LACONICD_CHAIN_ID=laconic-mainnet
```
* Restart the deployment:
```bash
laconic-so deployment --dir $CONSOLE_DEPLOYMENT stop
laconic-so deployment --dir $CONSOLE_DEPLOYMENT start
# Follow logs for console container
laconic-so deployment --dir $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
```
* Update the code for shopify app in [theme/sections/main-product.liquid](https://git.vdb.to/cerc-io/shopify/pulls/13/files#diff-971bd0e0a616c3feaecf3205ac98a23296a5a0d7) to use the correct chain ID
```bash
...
<script>
// Function to send a message to the iframe to get or create wallet account
function requestWalletAddress(iframe) {
const message = {
type: 'REQUEST_CREATE_OR_GET_ACCOUNTS',
# Replace `laconic-testnet-2` with `laconic-mainnet`
chainId: 'laconic-testnet-2',
};
...
```
* 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
* Deployment dir: `/srv/service-provider/webapp-deployer` and `/srv/service-provider/webapp-ui`
* Set deployment directory in a variable:
```bash
SP_DEPLOYMENT=/srv/service-provider/webapp-deployer
SP_UI_DEPLOYMENT=/srv/service-provider/webapp-ui
```
* Stop the deployments:
```bash
laconic-so deployment --dir $SP_DEPLOYMENT stop
laconic-so deployment --dir $SP_UI_DEPLOYMENT stop
```
* Update the laconic registry config with new endpoints:
```bash
nano $SP_DEPLOYMENT/data/config/laconic.yml
```
```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 $SP_DEPLOYMENT 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:
```bash
nano $SP_UI_DEPLOYMENT/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 $SP_UI_DEPLOYMENT start
```
* Check logs
```bash
laconic-so deployment --dir $SP_UI_DEPLOYMENT logs webapp
```
## Deploy Backend
* Deployment dir: `/srv/deploy-backend/laconic-backend-deployment`
* Stop the deployment:
```bash
laconic-so deployment --dir laconic-backend-deployment stop
```
* 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 --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 start
```
* Check logs:
```bash
laconic-so deployment --dir laconic-backend-deployment logs snowballtools-base-backend
```
## Deploy Frontend
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>
* Merge the following PRs in order to deploy frontend app with mainnet configuration
* <https://git.vdb.to/cerc-io/snowballtools-base/pulls/59>
* <https://git.vdb.to/cerc-io/snowballtools-base/pulls/58>
NOTE: Follow steps below if CI deployment doesn't work (cancel CI before following steps below)
### 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](https://webapp-deployer-ui.apps.vaasl.io/)
* On a successful deployment, the frontend can be viewed at <https://deploy.laconic.com>