Skip to main content

Setting Up Dynamic Deployer Service

Dynamic Deployer offers APIs that allows you to deploy and manage your projects. Follow these steps to set up your dyamic deployer service.

1. Create a Vercel Account and Generate Token

  • Go to the Vercel website and sign up for an account.
  • Once registered, log in to your Vercel account.
  • Navigate to your account settings and generate a Vercel token. You can do this by going to Account -> Tokens and create a new token. Keep this token secure, as it will be used for making deployment API calls

2. Fork whitelabel-bot github repository

  • Go to whitelabel-bot GitHub repository that contains the code for pwa bot.
  • Click on the Fork button in the top-right corner to fork the repository into your GitHub organization account.

3. Import the Project into Vercel

  • Visit the Vercel website.
  • Click on the Import Project button.
  • Choose your forked repository from the list and import it into Vercel.

Once the whitelabel-bot repository is imported to vercel, we can now use dynamic deployer APIs to add it as a project, and create deployments for it.

4. Setting up ENV Variables required for dynamic deployer service

List of enviornment variables

DATABASE_URL="postgresql://johndoe:randompassword@localhost:6543/mydb?schema=public"
VERCEL_TOKEN="<GENERATED FROM STEP 1>"
PWA_REPO="BharatSahAIyak/whitelabel-bot" # "<your-org-name>/<whitelabel-bot-fork-name>"
SELF_BASE_URL="<URL TO THIS SERVICE>"

# Connection to minio
STORAGE_CONTAINER_NAME=
STORAGE_ENDPOINT=
STORAGE_PORT=
STORAGE_USE_SSL='true' # or 'false'
STORAGE_ACCESS_KEY= # minio access key
STORAGE_SECRET_KEY= # minio secret key
STORAGE_MODE="minio" # or 's3'
MINIO_BUCKETNAME= # your bucket name

API_PORT= # port to run this service on

5. Adding project through API

Once the service is up and running, hit the following API to add a project for above provided PWA_REPO.

curl --location 'http://localhost:3000/project/create-new' \
--header 'Content-Type: application/json' \
--data '{
"name": "my-new-bot",
"env": {
"NEXT_PUBLIC_USER_SERVICE_APP_ID": "<val>",
"NEXT_PUBLIC_FLAGSMITH_ENVIRONMENT_ID": "<val>",
"NEXT_PUBLIC_SOCKET_URL": "<val>",
"NEXT_PUBLIC_BFF_API_URL": "<val>",
"NEXT_PUBLIC_JWKS_URI": "<val>",
"NEXT_PUBLIC_USER_SERVICE_URL": "<val>"
}
}'

Vercel limits to have only 3 projects linked to a github repository.

6. Deploying project throught API

Once the project is added, use the following API to create a deployment.

curl --location 'http://localhost:3000/deployment/create-new' \
--header 'Content-Type: application/json' \
--data '{
"name": "new-deployment",
"projectName": "my-new-bot",
"env": {
"ENVIORNMENT_ONE": "value_one",
"ANOTHER_ENV": "another_env_value"
},
"config": {
"theme": {
"primaryColor": {
"value": "#f70202",
"allowOverride": true
},
"secondaryColor": {
"value": "#011df4",
"allowOverride": true
}
},
"component": {
"navbar": {
"leftLogo": "http://localhost:9000/vercel-wrapper-bucket/logo.png",
"brandName": "test bot 2",
"centerLogo": "http://localhost:9000/vercel-wrapper-bucket/logo.png",
"allowOverride": true
}
}
}
}'

Deployment name can be anything, projectName should match the project name while adding the project through API, env is optional and can be used to update existing ENV variabled for that project, config helps rending the pwa bot. In response you get a deployment id. Which can then be used to get the deployment status for that project.

7. Checking deployment status

Use the following API to get deployment status

curl --location 'http://localhost:3000/deployment/status/1'

Response

{
"status": "SUCCESS",
"name": "new-deployment",
"vercelDomain": "whitelabel-pwa.vercel.app",
"message": ""
}

You can then follow the vercelDomain to checkout the deployment.