Skip to main content

Container Apps

This guide provides a step-by-step approach to deploying GoRules BRMS, a containerized application, using Azure Container Apps and Azure Database for PostgreSQL flexible servers. The deployment strategy outlined here aims to achieve a scalable, cost-effective, and easily maintainable infrastructure.

Overview of Components

  1. GoRules BRMS: Our containerized application
  2. Azure Container Apps: Serverless compute engine for containers
  3. Azure Database for PostgreSQL flexible servers: Managed PostreSQL relational database

In the following sections, we'll cover the configuration of each component, networking setup, security considerations, and deployment process. This guide assumes familiarity with Azure, Docker, and general DevOps practices.

Database - Setting Up Azure Database for PostgreSQL flexible servers

1. Initiate Database Creation

  1. Log in to Azure Portal - Navigate to the Azure Portal and sign in with your Microsoft account credentials.
  2. Create a New Resource - Click on “Create a resource” button, search for "Azure Database for PostgreSQL Flexible Server", and click on "Create".

2. Project Details section

  1. In Project details section select your Azure subscription, and choose or create a new resource group.

3. Server Details section

  1. Enter a unique name for your server in Server name
  2. Select the Azure region where you will host BMRS
  3. Select PostgreSQL version 16
  4. Next, select workload type, for example Production (Small / Medium) – you can further customize it to 2vCores and 8GB Ram. High availability is suggested for production setup.

4. Authentication section

  1. Select PostgreSQL authentication only
  2. Set an admin username and password
  3. IMPORTANT: Remember USERNAME and PASSWORD

5. Networking tab

  1. Choose your connectivity method and set up firewall rules if needed.

6. Security tab

  1. Select Service-managed key

7. Review and Create

  1. Review your settings and click “Create” to deploy your PostgreSQL server.

8. Create DB and get configuration

  1. After deployment, go to your resource list
  2. Open newly created server
  3. Go to overview menu and on the right side press copy of the Server Name
  4. IMPORTANT: remember SERVERNAME / HOST
  5. From the side menu select Databases and press Add.
  6. Enter name for example gorules-dev and press “Save”. (remember DATABASE)
  7. IMPORTANT: Remember DATABASE
  8. From the side menu, select Networking and Download SSL Certificate
  9. Use our online tool to convert certificate to base64
info

Remember to never commit sensitive information like database passwords to your version control system. Always use environment variables or a secure secrets management solution in your deployment process.

info

Your Database should not be public

Container Runner - Setting up Container Apps

1. Create Container Apps

  1. Click on “Create a resource”
  2. Search for “Container Apps”
  3. Select and click “Create”

2. Basics Tab

  1. Choose your subscription
  2. Chose or create Resource group
  3. Enter container app name
  4. Deployment source select Container image

3. Container Apps Environment

  1. Select region (same as Database)
  2. For a simple setup leave managedEnvironment in Environments but for more complex setup we would suggest setting your Environment manually

4. Container tab and finalization

  1. Select use quickstart image (we will configure proper image later)
  2. Skip bindings and tags and go to Review and Create
  3. Review your settings, and click “Create” to deploy your container app.

5. Configuring Container Apps

  1. Once deployed, open newly created Container App. From the left menu go to Overview menu, copy new URL
  2. IMPORTANT: Remember URL
  3. Open Containers menu and click Edit and Deploy.
  4. Container tab, Container Images section, select the image and click Edit
  5. In the newly opened Properties tab:
    1. Name: enter container app name,
    2. Image source: select Docker Hub or other registries
    3. Image type: Public
    4. Registry login: leave docker.io
    5. Image and tag: gorules/brms:latest (you should not use latest version in product but a specific image version)
    6. You can select initially 1 CPU cores and 2GI Memory
  6. Open Environment Variables tab (manual entries)
    • DB_HOST (DB 8.1 section)
    • DB_USER (DB 4.3 section)
    • DB_PASSWORD (DB 4.3 section - should be set in the vault and should come from vault)
    • DB_NAME (DB 8.7 section)
    • DB_REJECT_UNAUTHORIZED true
    • DB_SSL_CA (DB 8.9 - base64 encoded certificate)
    • LICENSE_KEY (from https://portal.gorules.io)
    • APP_NAME: Company DEV
    • APP_URL: (copy from Container App 5.2)
    • COOKIE_SECRET: // should come from vault
  7. Open Health Probes Tab
    1. Enable all 3 probes (Liveness, Readiness, Startup)
    2. Set values to all:
    3. Path to be /api/health
    4. Initial delay: 5
    5. Leave other config default
  8. Press Save and close - side drawer will close
  9. Open Scale tab, enter min replicas 1, max replicas 2 for dev environment (min 2 for Production)
  10. Press Create

6. Finalize

  1. Monitor status in Revisions and Replicas menu.
  2. Upon successful deployment, in Overview menu, open Application URL link.