diff --git a/README.md b/README.md index 71402e1..93bc676 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,5 @@ - **Deploy Cosmos Multisig App:** Integrate and run the Cosmos Multisig app using the playbook available at [cosmos-multisig-app playbook](./playbooks/cosmos-multisig-app/README.md) - **Run Subsequent Validator Nodes:** Run subsequent validator nodes by following the instructions in [run-validator.md](docs/run-validator.md) + +- To migrate existing deployments from SAPO testnet to mainnet, refer to [update-deployments.md](docs/update-deployments.md) diff --git a/docs/update-deployments.md b/docs/update-deployments.md new file mode 100644 index 0000000..dbe1365 --- /dev/null +++ b/docs/update-deployments.md @@ -0,0 +1,254 @@ +# Update deployments after code changes + +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, or checkout to the required branch + git pull + + # Confirm the latest commit hash + git log + + # 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= + + # RPC URL for the mainnet node + CERC_LACONICD_RPC_URL= + ``` + +* 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 + +* 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, or checkout to the required branch + git pull + + # Confirm the latest commit hash + git log + + # 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= + ``` + +* 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 + +--- + +## 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` + +* 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 + +### Backend + +* Deployment dir: `/srv/service-provider/webapp-deployer` + +* If code has changed, fetch and build with updated source code: + + ```bash + laconic-so --stack webapp-deployer-backend setup-repositories --git-ssh --pull + + laconic-so --stack webapp-deployer-backend build-containers --force-rebuild + ``` + +* Update the configuration, if required in : + * `/srv/service-provider/webapp-deployer/data/config/laconic.yml` + * `/srv/service-provider/webapp-deployer/config.env` + +* Restart the deployment: + + ```bash + laconic-so deployment --dir webapp-deployer stop + + laconic-so deployment --dir webapp-deployer start + ``` + +* Load context for k8s + + ```bash + kubie ctx vs-narwhal + ``` + +* Copy the GPG key file to the webapp-deployer container + + ```bash + # Get the webapp-deployer pod id + 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 GPG key files to the pod + kubectl cp webapp-deployer/webapp-deployer-api.apps.vaasl.io.pgp.key $POD_ID:/app + kubectl cp webapp-deployer/webapp-deployer-api.apps.vaasl.io.pgp.pub $POD_ID:/app + ``` + +### Frontend + +* Deployment dir: `/srv/service-provider/webapp-ui` + +* If code has changed, fetch and build with updated source code: + + ```bash + cd ~/cerc/webapp-deployment-status-ui + + # Pull latest changes, or checkout to the required branch + git pull + + # Confirm the latest commit hash + git log + + laconic-so build-webapp --source-repo ~/cerc/webapp-deployment-status-ui + ``` + +* Modify `/srv/service-provider/webapp-ui/config.env` like [this Pull Request](https://git.vdb.to/cerc-io/webapp-deployment-status-ui/pulls/6) but with your host details. + +* Restart the deployment: + + ```bash + laconic-so deployment --dir webapp-ui stop + + laconic-so deployment --dir webapp-ui start + ``` + +## 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` + +* Restart the deployment: + + ```bash + laconic-so deployment --dir laconic-backend-deployment stop + + laconic-so deployment --dir laconic-backend-deployment start + ``` + +## Deply Frontend + +* Follow steps similar to [deployments-from-scratch.md](./deployments-from-scratch.md#deploy-frontend) to deploy the snowball frontend + * Use auhority `laconic-deploy` and the script `deploy-frontend.sh` instead