Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e549af394 | ||
|
|
2c7c40697a | ||
|
|
69df4089b0 | ||
|
|
0bf6a73570 | ||
|
|
4ead8033d6 | ||
|
|
8f54da2b02 | ||
|
|
c0e3e31a81 | ||
|
|
9aa34090ba |
@@ -6,6 +6,8 @@
|
||||
"scripts": {
|
||||
"dev": "NODE_OPTIONS='--inspect' next dev --turbopack",
|
||||
"build": "next build",
|
||||
"build:compile": "next build --experimental-build-mode compile",
|
||||
"build:generate": "next build --experimental-build-mode generate",
|
||||
"start": "next start",
|
||||
"lint": "biome check .",
|
||||
"lint:fix": "biome check --write .",
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
REGISTRY_BOND_ID=
|
||||
DEPLOYER_LRN=
|
||||
AUTHORITY=
|
||||
+45
-27
@@ -1,5 +1,9 @@
|
||||
# deployer
|
||||
|
||||
The following steps are for deploying the frontend app to vaasl webapp deployer.
|
||||
|
||||
Run these steps in the `apps/deployer/` directory:
|
||||
|
||||
- Install dependencies
|
||||
|
||||
```bash
|
||||
@@ -7,46 +11,60 @@
|
||||
```
|
||||
|
||||
```bash
|
||||
brew install jq # if you do not have jq installed already
|
||||
# if you do not have jq installed already
|
||||
brew install jq
|
||||
# OR
|
||||
sudo apt-get install jq
|
||||
```
|
||||
|
||||
- Run script to deploy app
|
||||
- Copy and update `.env`
|
||||
|
||||
- To deploy frontend app to `dashboard.staging.apps.snowballtools.com`
|
||||
```
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
```bash
|
||||
./deploy-frontend.staging.sh
|
||||
```
|
||||
Set the required variables:
|
||||
|
||||
- To deploy frontend app to `dashboard.apps.snowballtools.com`
|
||||
```
|
||||
REGISTRY_BOND_ID=230cfedda15e78edc8986dfcb870e1b618f65c56e38d2735476d2a8cb3f25e38
|
||||
DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io
|
||||
AUTHORITY=laconic
|
||||
```
|
||||
|
||||
```bash
|
||||
./deploy-frontend.sh
|
||||
```
|
||||
- Set the `userKey` in [config.yml](./config.yml)
|
||||
|
||||
Note: The `userKey` should be the private key of the account owning the bond set in `config.yml` (account address: `laconic13maulvmjxnyx3g855vk0lsv5aptf3rpxskynef`)
|
||||
|
||||
- Set the app env values in [deploy-frontend.sh](./deploy-frontend.sh) (Refer to main [readme](/readme.md#3-configure-environment-variables)):
|
||||
<!-- TODO: Set env values from a file -->
|
||||
|
||||
```sh
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: your_clerk_key
|
||||
CLERK_SECRET_KEY: your_clerk_secret
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL: https://wallet.laconic.com
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID: laconic-mainnet
|
||||
NEXT_PUBLIC_API_URL: https://deploy-backend.apps.vaasl.io
|
||||
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN: your_github_token
|
||||
```
|
||||
|
||||
NOTE: Replace `your_clerk_key`, `your_clerk_secret` and `your_github_token` with actual values
|
||||
|
||||
- Run script to deploy app to `deploy-staging.laconic.co`
|
||||
|
||||
```bash
|
||||
./deploy-frontend.sh
|
||||
```
|
||||
|
||||
- Commit the updated [ApplicationRecord](records/application-record.yml) and [ApplicationDeploymentRequest](records/application-deployment-request.yml) files to the repository
|
||||
|
||||
## Notes
|
||||
|
||||
- Any config env can be updated in [records/application-deployment-request.yml](records/application-deployment-request.yml)
|
||||
|
||||
```yml
|
||||
record:
|
||||
...
|
||||
config:
|
||||
env:
|
||||
LACONIC_HOSTED_CONFIG_app_server_url: https://snowballtools-base-api-001.apps.snowballtools.com
|
||||
...
|
||||
```
|
||||
|
||||
- On changing `LACONIC_HOSTED_CONFIG_app_github_clientid`, the GitHub client ID and secret need to be changed in backend config too
|
||||
|
||||
## Troubleshoot
|
||||
|
||||
- Check deployment status in [web-app deployer](https://console.laconic.com/deployer).
|
||||
|
||||
- Check records in [registry console app](https://console.laconic.com/#/registry).
|
||||
|
||||
- If deployment fails due to low bond balance
|
||||
|
||||
- Check balances
|
||||
|
||||
```bash
|
||||
@@ -54,11 +72,11 @@
|
||||
pnpm laconic registry account get
|
||||
|
||||
# Bond balance
|
||||
pnpm laconic registry bond get --id 99c0e9aec0ac1b8187faa579be3b54f93fafb6060ac1fd29170b860df605be32
|
||||
pnpm laconic registry bond get --id 230cfedda15e78edc8986dfcb870e1b618f65c56e38d2735476d2a8cb3f25e38
|
||||
```
|
||||
|
||||
- Command to refill bond
|
||||
|
||||
```bash
|
||||
pnpm laconic registry bond refill --id 99c0e9aec0ac1b8187faa579be3b54f93fafb6060ac1fd29170b860df605be32 --type alnt --quantity 10000000
|
||||
pnpm laconic registry bond refill --id 230cfedda15e78edc8986dfcb870e1b618f65c56e38d2735476d2a8cb3f25e38 --type alnt --quantity 10000000
|
||||
```
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
services:
|
||||
registry:
|
||||
rpcEndpoint: https://laconicd-sapo.laconic.com
|
||||
gqlEndpoint: https://laconicd-sapo.laconic.com/api
|
||||
rpcEndpoint: https://laconicd-mainnet-1.laconic.com/
|
||||
gqlEndpoint: https://laconicd-mainnet-1.laconic.com/api
|
||||
userKey:
|
||||
bondId:
|
||||
chainId: laconic-testnet-2
|
||||
bondId: 230cfedda15e78edc8986dfcb870e1b618f65c56e38d2735476d2a8cb3f25e38
|
||||
chainId: laconic-mainnet
|
||||
gasPrice: 0.001alnt
|
||||
|
||||
@@ -6,10 +6,10 @@ echo "Using DEPLOYER_LRN: $DEPLOYER_LRN"
|
||||
echo "Using AUTHORITY: $AUTHORITY"
|
||||
|
||||
# Repository URL
|
||||
REPO_URL="https://git.vdb.to/cerc-io/snowballtools-base"
|
||||
REPO_URL="https://git.vdb.to/deep-stack/laconic-deployer-frontend"
|
||||
|
||||
# Get the latest commit hash for a branch
|
||||
BRANCH_NAME="main"
|
||||
BRANCH_NAME="ng-deploy-with-fixes"
|
||||
LATEST_HASH=$(git ls-remote $REPO_URL refs/heads/$BRANCH_NAME | awk '{print $1}')
|
||||
|
||||
echo "Latest commit hash for branch $BRANCH_NAME: $LATEST_HASH"
|
||||
@@ -25,7 +25,7 @@ CONFIG_FILE=config.yml
|
||||
# Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts
|
||||
|
||||
# Get latest version from registry and increment application-record version
|
||||
NEW_APPLICATION_VERSION=$(pnpm --silent laconic -c $CONFIG_FILE registry record list --type ApplicationRecord --all --name "deploy-frontend" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
NEW_APPLICATION_VERSION=$(pnpm --silent laconic -c $CONFIG_FILE registry record list --type ApplicationRecord --all --name "laconic-deployer-frontend" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
|
||||
if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then
|
||||
# Set application-record version if no previous records were found
|
||||
@@ -39,8 +39,8 @@ record:
|
||||
version: $NEW_APPLICATION_VERSION
|
||||
repository_ref: $LATEST_HASH
|
||||
repository: ["$REPO_URL"]
|
||||
app_type: webapp
|
||||
name: deploy-frontend
|
||||
app_type: webapp/next
|
||||
name: laconic-deployer-frontend
|
||||
app_version: $PACKAGE_VERSION
|
||||
EOF
|
||||
|
||||
@@ -60,7 +60,7 @@ echo "ApplicationRecord published"
|
||||
echo $RECORD_ID
|
||||
|
||||
# Set name to record
|
||||
REGISTRY_APP_LRN="lrn://$AUTHORITY/applications/deploy-frontend"
|
||||
REGISTRY_APP_LRN="lrn://$AUTHORITY/applications/laconic-deployer-frontend"
|
||||
|
||||
sleep 2
|
||||
pnpm --silent laconic -c $CONFIG_FILE registry name set "$REGISTRY_APP_LRN@${PACKAGE_VERSION}" "$RECORD_ID"
|
||||
@@ -122,19 +122,18 @@ cat >./records/application-deployment-request.yml <<EOF
|
||||
record:
|
||||
type: ApplicationDeploymentRequest
|
||||
version: '1.0.0'
|
||||
name: deploy-frontend@$PACKAGE_VERSION
|
||||
application: lrn://$AUTHORITY/applications/deploy-frontend@$PACKAGE_VERSION
|
||||
name: laconic-deployer-frontend@$PACKAGE_VERSION
|
||||
application: lrn://$AUTHORITY/applications/laconic-deployer-frontend@$PACKAGE_VERSION
|
||||
deployer: $DEPLOYER_LRN
|
||||
dns: deploy.laconic.com
|
||||
dns: deploy-staging.apps.vaasl.io
|
||||
config:
|
||||
env:
|
||||
LACONIC_HOSTED_CONFIG_server_url: https://deploy-backend.laconic.com
|
||||
LACONIC_HOSTED_CONFIG_github_clientid: Ov23li4NtYybQlF6u5Dk
|
||||
LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
||||
LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
||||
LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
||||
LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2
|
||||
LACONIC_HOSTED_CONFIG_wallet_iframe_url: https://wallet.laconic.com
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL: https://wallet.laconic.com
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID: laconic-mainnet
|
||||
NEXT_PUBLIC_API_URL: https://deploy-backend.apps.vaasl.io
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: pk_test_d2VsbC1tYW5hdGVlLTQxLmNsZXJrLmFjY291bnRzLmRldiQ
|
||||
CLERK_SECRET_KEY: sk_test_KjVFQ8zzVN7GMtxIgVWTne2YN0FD63gvB5hsfpLiRZ
|
||||
NEXT_PUBLIC_GITHUB_BACKEND_CLIENT_ID: Ov23liaet4yc0KX0iM1c
|
||||
meta:
|
||||
note: Added @ $CURRENT_DATE_TIME
|
||||
repository: "$REPO_URL"
|
||||
@@ -142,6 +141,12 @@ record:
|
||||
payment: $txHash
|
||||
EOF
|
||||
|
||||
# Old env values for frontend app
|
||||
# LACONIC_HOSTED_CONFIG_github_clientid: Ov23li4NtYybQlF6u5Dk
|
||||
# LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
|
||||
# LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
|
||||
# LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
|
||||
|
||||
RECORD_FILE=records/application-deployment-request.yml
|
||||
|
||||
sleep 2
|
||||
|
||||
+7
-12
@@ -3,19 +3,14 @@
|
||||
PKG_DIR="./apps/deploy-fe"
|
||||
|
||||
cat > $PKG_DIR/.env <<EOF
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL=https://wallet.laconic.com
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID=laconic-mainnet
|
||||
NEXT_PUBLIC_API_URL=https://deploy-backend.apps.vaasl.io
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_d2VsbC1tYW5hdGVlLTQxLmNsZXJrLmFjY291bnRzLmRldiQ
|
||||
CLERK_SECRET_KEY=sk_test_KjVFQ8zzVN7GMtxIgVWTne2YN0FD63gvB5hsfpLiRZ
|
||||
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN=your_github_token
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=CERC_RUNTIME_ENV_NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
||||
CLERK_SECRET_KEY=CERC_RUNTIME_ENV_CLERK_SECRET_KEY
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL=CERC_RUNTIME_ENV_NEXT_PUBLIC_WALLET_IFRAME_URL
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID=CERC_RUNTIME_ENV_NEXT_PUBLIC_LACONICD_CHAIN_ID
|
||||
NEXT_PUBLIC_API_URL=CERC_RUNTIME_ENV_NEXT_PUBLIC_API_URL
|
||||
NEXT_PUBLIC_GITHUB_BACKEND_CLIENT_ID=CERC_RUNTIME_ENV_NEXT_PUBLIC_GITHUB_BACKEND_CLIENT_ID
|
||||
EOF
|
||||
|
||||
cat $PKG_DIR/.env
|
||||
|
||||
pnpm install || exit 1
|
||||
|
||||
# TODO: Fix build script to run
|
||||
pnpm build --filter deploy-fe || exit 1
|
||||
|
||||
#pnpm build --filter @workspace/gql-client || exit 1
|
||||
pnpm build:fe-compile || exit 1
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "turbo build",
|
||||
"build:fe-compile": "turbo build:compile --filter=deploy-fe",
|
||||
"dev": "turbo dev",
|
||||
"lint": "turbo lint",
|
||||
"start": "turbo start",
|
||||
|
||||
Generated
+22
-2061
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,7 @@ Create a `.env.local` file in the `apps/deploy-fe` directory:
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
|
||||
CLERK_SECRET_KEY=your_clerk_secret
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL=http://localhost:4000
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID=laconic-testnet-2
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID=laconic-mainnet
|
||||
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN=your_github_token
|
||||
```
|
||||
@@ -92,4 +92,26 @@ The frontend is built with:
|
||||
Make sure you have:
|
||||
1. Connected your GitHub account in Clerk
|
||||
2. Provided the necessary permissions for repository access
|
||||
3. Set a fallback GitHub token in `.env.local` if needed for development
|
||||
3. Set a fallback GitHub token in `.env.local` if needed for development
|
||||
|
||||
## Test deployment
|
||||
|
||||
- Follow the dev install steps for stack-orchestrator from <https://git.vdb.to/cerc-io/stack-orchestrator/src/branch/main/docs/CONTRIBUTING.md#install>
|
||||
|
||||
- Build the container for app
|
||||
|
||||
```bash
|
||||
laconic-so build-webapp --source-repo <path-to-app-repo>/laconic-deployer-frontend --base-container cerc/nextjs-base
|
||||
```
|
||||
|
||||
- Create an env file as described in [previous steps](#3-configure-environment-variables)
|
||||
|
||||
- Run the webapp container locally
|
||||
|
||||
```bash
|
||||
docker run -p 3000:80 --env-file <path-to-env-file> cerc/laconic-deployer-frontend:local
|
||||
```
|
||||
|
||||
- Scripts used for deployment
|
||||
- App container build : [build-webapp.sh](./build-webapp.sh)
|
||||
- Run app container : [run-webapp.sh](./run-webapp.sh)
|
||||
|
||||
+10
-15
@@ -1,22 +1,17 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
SCRIPT_DIR=/scripts/
|
||||
|
||||
PKG_DIR="./apps/deploy-fe"
|
||||
|
||||
cd $PKG_DIR
|
||||
|
||||
cat > .env.local <<EOF
|
||||
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}
|
||||
CLERK_SECRET_KEY=${CLERK_SECRET_KEY}
|
||||
NEXT_PUBLIC_WALLET_IFRAME_URL=${NEXT_PUBLIC_WALLET_IFRAME_URL}
|
||||
NEXT_PUBLIC_LACONICD_CHAIN_ID=${NEXT_PUBLIC_LACONICD_CHAIN_ID}
|
||||
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN=${NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN}
|
||||
EOF
|
||||
"$SCRIPT_DIR/apply-runtime-env.sh" "`pwd`" .next .next-r
|
||||
mv .next .next.old
|
||||
mv .next-r/.next .
|
||||
|
||||
# For debugging
|
||||
# cat .env.local
|
||||
pnpm build:generate || exit 1
|
||||
|
||||
# TODO: Need production build in .next. Check build-webapp.sh
|
||||
pnpm start -p ${CERC_LISTEN_PORT:-80}
|
||||
|
||||
#pnpm dev -p ${CERC_LISTEN_PORT:-80}
|
||||
@@ -8,6 +8,11 @@
|
||||
"outputs": [".next/**", "!.next/cache/**"],
|
||||
"env": ["NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY", "CLERK_SECRET_KEY"]
|
||||
},
|
||||
"build:compile": {
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["$TURBO_DEFAULT$"],
|
||||
"outputs": ["dist/**"]
|
||||
},
|
||||
"start": {
|
||||
"dependsOn": ["^build"],
|
||||
"cache": false,
|
||||
|
||||
Reference in New Issue
Block a user