Skip to content

Cloud-based deployment with Azure Container Instances

This guide provides instructions for deploying SerenityGPT using Azure Container Instances (ACI). This deployment option offers a managed cloud infrastructure solution, ideal for production environments.

Cloud Flexibility

Deploying SerenityGPT on Azure Container Instances offers scalability and ease of management. This guide provides a foundation that can be adapted to other cloud providers with similar container services.

Prerequisites

Security considerations

When deploying to the cloud, ensure you follow your organization's security policies. Pay special attention to network security, access controls, and data encryption in transit and at rest.

Before you begin, ensure you have:

  • An Azure account with an active subscription.
  • Azure CLI installed and configured.
  • Access to the SerenityGPT container registry.
  • Your SerenityGPT license key.
  • A PostgreSQL database with pgvector extension (see Provisioning a Database).

Steps

  1. Create an Azure Resource Group.
  2. Create an Azure Container Registry (ACR).
  3. Push the SerenityGPT image to ACR.
  4. Deploy SerenityGPT using Azure Container Instances.
  5. Configure networking and security.
  6. Verify the deployment.

1. Create an Azure Resource Group

az group create --name serenityGPTResourceGroup --location eastus

2. Create an Azure Container Registry

az acr create --resource-group serenityGPTResourceGroup --name serenityGPTRegistry --sku Basic

3. Push the SerenityGPT image to ACR

First, log in to your ACR:

az acr login --name serenityGPTRegistry

Then, tag and push the SerenityGPT image:

docker tag serenitygpt.azurecr.io/serenitygpt:latest serenityGPTRegistry.azurecr.io/serenitygpt:latest
docker push serenityGPTRegistry.azurecr.io/serenitygpt:latest

Image versioning

Consider using specific version tags instead of 'latest' for production deployments. This practice ensures consistency and makes it easier to roll back if needed.

4. Deploy SerenityGPT using Azure Container Instances

Create a deployment YAML file named serenityGPT-aci.yaml:

apiVersion: 2019-12-01
location: eastus
name: serenitygpt-container
properties:
  containers:
  - name: serenitygpt
    properties:
      image: serenityGPTRegistry.azurecr.io/serenitygpt:latest
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
      - port: 8080
      environmentVariables:
      - name: DB_NAME
        value: serenitydb
      - name: DB_USER
        value: your_db_user
      - name: DB_PASSWORD
        secureValue: your_db_password
      - name: DB_HOST
        value: your_db_host
      - name: DB_PORT
        value: "5432"
      - name: AAD_TENANT_ID
        value: your_tenant_id
      - name: AAD_CLIENT_ID
        value: your_client_id
      - name: AAD_CLIENT_SECRET
        secureValue: your_client_secret
      - name: AAD_REDIRECT_URI
        value: https://your-serenitygpt-hostname/login/aad/callback
  osType: Linux
  restartPolicy: Always
  ipAddress:
    type: Public
    ports:
    - protocol: tcp
      port: 8080
  imageRegistryCredentials:
  - server: serenityGPTRegistry.azurecr.io
    username: serenityGPTRegistry
    password: your_acr_password
tags: {application: serenitygpt}
type: Microsoft.ContainerInstance/containerGroups

Sensitive Information

The YAML file contains sensitive information. In a production environment, use Azure Key Vault or a similar service to manage secrets securely.

Deploy the container:

az container create --resource-group serenityGPTResourceGroup --file serenityGPT-aci.yaml

5. Configure networking and security

Set up a custom domain and SSL certificate:

az network dns record-set a add-record -g serenityGPTResourceGroup -z yourdomain.com -n serenitygpt -a <ACI_IP_ADDRESS>
az network application-gateway ssl-cert create -g serenityGPTResourceGroup --gateway-name serenityGPTAppGateway -n serenityGPTCert --cert-file /path/to/your/certificate.pfx --cert-password your_cert_password

Custom domain

Using a custom domain with proper SSL/TLS configuration enhances both the professional appearance and security of your SerenityGPT deployment.

6. Verify the deployment

Check the container status:

az container show --resource-group serenityGPTResourceGroup --name serenitygpt-container --query instanceView.state

Access the SerenityGPT web interface using the public IP address or custom domain you configured.

Scaling and Monitoring

To scale your deployment:

az container update --resource-group serenityGPTResourceGroup --name serenitygpt-container --cpu 2 --memory 3

Autoscaling

For production environments, consider setting up autoscaling rules based on CPU usage or custom metrics to automatically handle varying loads. Multiple instances of the serenity-web container can be created and scaled in parallel to meet the expected load.

Set up Azure Monitor for container insights:

az monitor diagnostic-settings create --resource-group serenityGPTResourceGroup --resource-type Microsoft.ContainerInstance/containerGroups --resource-name serenitygpt-container --name serenityGPTMonitoring --workspace-name serenityGPTLogAnalytics --logs '[{"category": "ContainerInstanceLog","enabled": true}]' --metrics '[{"category": "AllMetrics","enabled": true}]'

Conclusion

You now have a production-ready SerenityGPT instance deployed on Azure Container Instances. This setup provides scalability, security, and easy management for your enterprise search solution.

Next steps

With your SerenityGPT instance now running on Azure Container Instances, consider setting up continuous deployment pipelines for seamless updates and exploring advanced monitoring options for optimal performance.

For more detailed configuration options and best practices, refer to our Configuration Reference.