Compare commits

..

No commits in common. "ng-update-deployer" and "main" have entirely different histories.

7 changed files with 29 additions and 126 deletions

View File

@ -1,3 +0,0 @@
REGISTRY_BOND_ID=
DEPLOYER_LRN=
AUTHORITY=

View File

@ -7,44 +7,22 @@
``` ```
```bash ```bash
# if you do not have jq installed already brew install jq # if you do not have jq installed already
brew install jq
# OR
sudo apt-get install jq
``` ```
- Copy and update `.env` - Run script to deploy app
``` - To deploy frontend app to `dashboard.staging.apps.snowballtools.com`
cp .env.example .env
```
Set the required variables: ```bash
./deploy-frontend.staging.sh
```
``` - To deploy frontend app to `dashboard.apps.snowballtools.com`
REGISTRY_BOND_ID=<bond-id>
DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io
AUTHORITY=vaasl
```
Note: The bond id should be set to the `vaasl` authority ```bash
./deploy-frontend.sh
- Set the `userKey` and `bondId` in [config.yml](./config.yml) ```
Note: The `bondId` should be created by the `userKey` account
- Set the actual values for env in [deploy-frontend.sh](./deploy-frontend.sh) for the following:
```sh
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
CLERK_SECRET_KEY=your_clerk_secret
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN=your_github_token
```
- Run script to deploy app to `deploy.laconic.com`
```bash
./deploy-frontend.sh
```
- Commit the updated [ApplicationRecord](records/application-record.yml) and [ApplicationDeploymentRequest](records/application-deployment-request.yml) files to the repository - Commit the updated [ApplicationRecord](records/application-record.yml) and [ApplicationDeploymentRequest](records/application-deployment-request.yml) files to the repository

View File

@ -1,8 +1,8 @@
services: services:
registry: registry:
rpcEndpoint: https://laconicd-mainnet-1.laconic.com/ rpcEndpoint: https://laconicd-sapo.laconic.com
gqlEndpoint: https://laconicd-mainnet-1.laconic.com/api gqlEndpoint: https://laconicd-sapo.laconic.com/api
userKey: userKey:
bondId: bondId:
chainId: laconic-mainnet chainId: laconic-testnet-2
gasPrice: 0.001alnt gasPrice: 0.001alnt

View File

@ -6,7 +6,7 @@ echo "Using DEPLOYER_LRN: $DEPLOYER_LRN"
echo "Using AUTHORITY: $AUTHORITY" echo "Using AUTHORITY: $AUTHORITY"
# Repository URL # Repository URL
REPO_URL="https://git.vdb.to/NasSharaf/laconic-deployer-frontend" REPO_URL="https://git.vdb.to/cerc-io/snowballtools-base"
# Get the latest commit hash for a branch # Get the latest commit hash for a branch
BRANCH_NAME="main" BRANCH_NAME="main"
@ -25,7 +25,7 @@ CONFIG_FILE=config.yml
# Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts # 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 # 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 "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}') 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}')
if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then
# Set application-record version if no previous records were found # Set application-record version if no previous records were found
@ -39,8 +39,8 @@ record:
version: $NEW_APPLICATION_VERSION version: $NEW_APPLICATION_VERSION
repository_ref: $LATEST_HASH repository_ref: $LATEST_HASH
repository: ["$REPO_URL"] repository: ["$REPO_URL"]
app_type: webapp/next app_type: webapp
name: laconic-deployer-frontend name: deploy-frontend
app_version: $PACKAGE_VERSION app_version: $PACKAGE_VERSION
EOF EOF
@ -60,7 +60,7 @@ echo "ApplicationRecord published"
echo $RECORD_ID echo $RECORD_ID
# Set name to record # Set name to record
REGISTRY_APP_LRN="lrn://$AUTHORITY/applications/laconic-deployer-frontend" REGISTRY_APP_LRN="lrn://$AUTHORITY/applications/deploy-frontend"
sleep 2 sleep 2
pnpm --silent laconic -c $CONFIG_FILE registry name set "$REGISTRY_APP_LRN@${PACKAGE_VERSION}" "$RECORD_ID" pnpm --silent laconic -c $CONFIG_FILE registry name set "$REGISTRY_APP_LRN@${PACKAGE_VERSION}" "$RECORD_ID"
@ -122,18 +122,19 @@ cat >./records/application-deployment-request.yml <<EOF
record: record:
type: ApplicationDeploymentRequest type: ApplicationDeploymentRequest
version: '1.0.0' version: '1.0.0'
name: laconic-deployer-frontend@$PACKAGE_VERSION name: deploy-frontend@$PACKAGE_VERSION
application: lrn://$AUTHORITY/applications/laconic-deployer-frontend@$PACKAGE_VERSION application: lrn://$AUTHORITY/applications/deploy-frontend@$PACKAGE_VERSION
deployer: $DEPLOYER_LRN deployer: $DEPLOYER_LRN
dns: deploy-staging.laconic.com dns: deploy.laconic.com
config: config:
env: env:
NEXT_PUBLIC_WALLET_IFRAME_URL=https://wallet.laconic.com LACONIC_HOSTED_CONFIG_server_url: https://deploy-backend.laconic.com
NEXT_PUBLIC_LACONICD_CHAIN_ID=laconic-mainnet LACONIC_HOSTED_CONFIG_github_clientid: Ov23li4NtYybQlF6u5Dk
NEXT_PUBLIC_API_URL=https://deploy-backend.laconic.com LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example
CLERK_SECRET_KEY=your_clerk_secret LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind
NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN=your_github_token LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2
LACONIC_HOSTED_CONFIG_wallet_iframe_url: https://wallet.laconic.com
meta: meta:
note: Added @ $CURRENT_DATE_TIME note: Added @ $CURRENT_DATE_TIME
repository: "$REPO_URL" repository: "$REPO_URL"
@ -141,12 +142,6 @@ record:
payment: $txHash payment: $txHash
EOF 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 RECORD_FILE=records/application-deployment-request.yml
sleep 2 sleep 2

View File

@ -1,19 +0,0 @@
#!/bin/bash
PKG_DIR="./apps/deploy-fe"
cat > $PKG_DIR/.env <<EOF
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_FALLBACK_TOKEN=CERC_RUNTIME_ENV_NEXT_PUBLIC_GITHUB_FALLBACK_TOKEN
EOF
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

View File

@ -92,30 +92,4 @@ The frontend is built with:
Make sure you have: Make sure you have:
1. Connected your GitHub account in Clerk 1. Connected your GitHub account in Clerk
2. Provided the necessary permissions for repository access 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>
<!-- TODO: Remove after SO PR https://git.vdb.to/cerc-io/stack-orchestrator/pulls/969 is merged -->
- Change branch
```bash
git checkout ng-support-custom-nextjs
```
- 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:3000 --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)

View File

@ -1,22 +0,0 @@
#!/bin/bash
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
# For debugging
# cat .env.local
# TODO: Need production build in .next. Check build-webapp.sh
# pnpm start
pnpm dev