Deployment
Follow Deployment Best Practices Checklist to ensure you’ve implemented proper observability, performance optimizations, and security measures.
Prerequisite
- An account on a cloud provider (such as AWS, Azure and, Google Coud)
- Install and configure the following tools:
- Docker
- Serverless Framework
- Database Systems (e.g., Redis and PostgreSQL)
- Cloud provider CLI tools (such as AWS CLI, Azure CLI, or Google Cloud SDK)
Pre-deployment
Once you have completed the development and local testing of your extension, the next step is to deploy it to a cloud provider of your choice.
Key considerations for production deployment:
- Create Reddis Cluster on AWS or Redis instance on Microsift Azure or Redis instance on Google Cloud Memorystore
- Environment Variables: Update the .env file with the following credentials:
- API key, secret, and launch URL for the production environment
EXTENSION_API_KEY=<api_key>
EXTENSION_API_SECRET=<api_secret>
EXTENSION_BASE_URL=<base_url> - Reddis credential and port
REDIS_HOST=your-redis-host
REDIS_PORT=6379
REDIS_PASSWORD=your-redis-password
- API key, secret, and launch URL for the production environment
- Configution of Database System
- Configuration of Docker to Deploy the Image to the Registry
Configuration of Database System
You need to configure a database system before proceeding with deployment. While partners can choose any database solution that best fits their use case, we are configuring Redis because Redis is commonly used for caching, real-time data processing, and session management due to its high performance and in-memory data storage capabilities.
- In the boilerplate codebase, open the server.js file and replace the default FDK setup configuration with Redis integration logic. This is required to enable Redis-based session or data storage within your extension.
const RedisStorage = require('@gofynd/fdk-extension-javascript/express/storage/redis_storage');
const redis = require('redis');
const redisClient = redis.createClient({
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: process.env.REDIS_PASSWORD,
});
const fdkExtension = setupFdk({
api_key: process.env.EXTENSION_API_KEY,
api_secret: process.env.EXTENSION_API_SECRET,
base_url: process.env.EXTENSION_BASE_URL,
cluster: process.env.FP_API_DOMAIN,
callbacks: {
auth: async (req) => {
if (req.query.application_id)
return `${req.extension.base_url}/company/${req.query['company_id']}/application/${req.query.application_id}`;
else
return `${req.extension.base_url}/company/${req.query['company_id']}`;
},
uninstall: async (req) => {
// Cleanup tasks
}
},
storage: new RedisStorage(redisClient, "example-fynd-platform-extension"), // add your prefix
access_mode: "offline",
webhook_config: {
api_path: "/api/webhook-events",
notification_email: "abc@gofynd.com",
event_map: {
'application/courier-partner/assign': {
handler: webhookHandler.courierPartnerAsign,
version: '1',
},
'application/courier-partner/cancel': {
handler: webhookHandler.courierPartnerCancel,
version: '1',
}
}
},
});
Configuration of Docker to Deploy Image to Registry
Docker allows you to containerize your application, making it easy to build, run, and deploy in any environment. Using the preconfigured Dockerfile in the boilerplate, you can quickly package your application and consistently deploy it across local, staging, or production environments.
Do the following steps to build, run, and push the Docker image to your selected container registry.
- Run the following command to build Docker image:
docker build -t your-app-name
- Run the following command to Docker Container Locally to verify the container runs correctly (Optional):
docker run -p 3000:3000 your-app-name
- Push the Docker image using the following command based on the cloud provider you have chosen in Pre-deployment:
- AWS ECR
- ACR
- GCR
aws ecr get-login-password --region your-region | docker login --username AWS --password-stdin your-account-id.dkr.ecr.your-region.amazonaws.com
docker tag your-app-name:latest your-account-id.dkr.ecr.your-region.amazonaws.com/your-app-name:latest
docker push your-account-id.dkr.ecr.your-region.amazonaws.com/your-app-name:latest
az acr login --name yourRegistryName
docker tag your-app-name yourRegistryName.azurecr.io/your-app-name
docker push yourRegistryName.azurecr.io/your-app-name
gcloud auth configure-docker
docker tag your-app-name gcr.io/your-project-id/your-app-name
docker push gcr.io/your-project-id/your-app-name
Deployment Methods
We recommend deploying your extension in a serverless manner for scalability and cost-effectiveness. Learn more about our Recommended Deployment Methods.