Skip to content

Commit

Permalink
Merge branch 'main' into test-deploy-middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator committed Dec 13, 2024
2 parents 39c1630 + c75061f commit 509a611
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: ./.github/actions/build-frontend
name: Build frontend
with:
api-endpoint: https://reportvision-middleware-dev.azurewebsites.net/
api-endpoint: https://reportvision-middleware-dev.azurewebsites.net
frontend-tarball: ./frontend.tgz
frontend-path: ./frontend
frontend-build-path: ./frontend/dist/
Expand Down
4 changes: 2 additions & 2 deletions frontend/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "./types/types";

const apiUrl = import.meta.env.VITE_API_URL || "http://localhost:8000/";
const middlewareURL = import.meta.env.VITE_MIDDLEWARE_API_URL || "http://localhost:8000/";
export const middlewareURL = import.meta.env.VITE_MIDDLEWARE_API_URL || "http://localhost:8000";

export const AlignImage = async (
args: AlignImageArgs,
Expand Down Expand Up @@ -44,7 +44,7 @@ export const ImageToText = async (
labels: JSON.stringify(fieldNames),
});

const imageToTextURL = `${middlewareURL}api/image_file_to_text`;
const imageToTextURL = `${middlewareURL}/api/image_file_to_text`;
try {
const response = await fetch(imageToTextURL, {
method: "POST",
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/types/templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Organization, Page, User } from "./models.ts";
import { create } from "zustand";
import { Shape } from "react-image-label";
import {middlewareURL} from "../../api/api.ts";

export interface Template {
id: string;
Expand All @@ -19,11 +20,9 @@ export interface Template {

type TemplateStatus = "Completed" | "In Progress" | "Deprecated";

const MIDDLEWARE_URL =
import.meta.env.VITE_MIDDLEWARE_API_URL || "http://localhost:8081";
export const TemplateAPI = {
getTemplates: async (): Promise<Template[]> => {
const response = await fetch(`${MIDDLEWARE_URL}/templates`);
const response = await fetch(`${middlewareURL}/templates`);
if (!response.ok) {
throw new Error("Unable to fetch templates");
}
Expand Down
2 changes: 2 additions & 0 deletions ops/terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ locals {
websubnetcidr = "10.0.3.0/24"
lbsubnetcidr = "10.0.4.0/24"
dbsubnetcidr = "10.0.5.0/24"
appgwsubnetcidr = "10.0.6.0/24"
}
}
demo = {
Expand All @@ -24,6 +25,7 @@ locals {
websubnetcidr = "10.1.3.0/24"
lbsubnetcidr = "10.1.4.0/24"
dbsubnetcidr = "10.1.5.0/24"
appgwsubnetcidr = "10.1.6.0/24"
}
}
}
9 changes: 5 additions & 4 deletions ops/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "networking" {
ocrsubnetcidr = local.workspace["ocrsubnetcidr"]
middlewaresubnetcidr = local.workspace["middlewaresubnetcidr"]
dbsubnetcidr = local.workspace["dbsubnetcidr"]
appgwsubnetcidr = local.workspace["appgwsubnetcidr"]
env = local.environment

# The DNS zone and DNS link are managed inside the networking module.
Expand All @@ -43,10 +44,10 @@ module "app_gateway" {
resource_group_location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name

blob_endpoint = module.storage.primary_web_host
lb_subnet = module.networking.lbsubnet_id
tags = local.management_tags
env = local.environment
blob_endpoint = module.storage.primary_web_host
appgw_subnet_id = module.networking.appgwsubnet_id
tags = local.management_tags
env = local.environment

fqdns_ocr = module.ocr_api.app_hostname
fqdns_middleware = module.middleware_api.app_hostname
Expand Down
29 changes: 19 additions & 10 deletions ops/terraform/modules/app_gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ resource "azurerm_application_gateway" "load_balancer" {
location = var.resource_group_location

sku {
name = "Standard_v2"
tier = "Standard_v2"
name = "WAF_v2"
tier = "WAF_v2" # WAF tier depreciated, set to WAF_v2 tier
# capacity = 2
}

autoscale_configuration {
min_capacity = 2
max_capacity = 5
}

# Enable Web Application Firewall
waf_configuration {
enabled = true
firewall_mode = "Prevention" # to block malicious traffic
rule_set_type = "OWASP"
rule_set_version = "3.2"
}

gateway_ip_configuration {
name = "${var.name}-gateway-ip-configuration"
subnet_id = var.lb_subnet
name = "${var.name}-gateway-ip-configuration-${var.env}"
subnet_id = var.appgw_subnet_id
}

# ------- Static -------------------------
Expand Down Expand Up @@ -272,9 +286,4 @@ resource "azurerm_application_gateway" "load_balancer" {
}
}
}

autoscale_configuration {
min_capacity = 0
max_capacity = 5
}
}
}
4 changes: 2 additions & 2 deletions ops/terraform/modules/app_gateway/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variable "name" {}
variable "resource_group_name" {}
variable "resource_group_location" {}
variable "lb_subnet" {}
variable "appgw_subnet_id" {}
variable "blob_endpoint" {}
variable "tags" {}

Expand All @@ -19,4 +19,4 @@ variable "ip_addresses" {
type = list(string)
default = []
}
variable "env" {}
variable "env" {}
11 changes: 11 additions & 0 deletions ops/terraform/modules/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ resource "azurerm_virtual_network" "vnet" {
address_space = [var.vnetcidr]
}

resource "azurerm_subnet" "appgw_subnet" {
name = "${var.name}-appgw-subnet-${var.env}"
virtual_network_name = azurerm_virtual_network.vnet.name
resource_group_name = var.resource_group
address_prefixes = [var.appgwsubnetcidr]
service_endpoints = [
"Microsoft.Sql",
"Microsoft.Storage",
]
}

resource "azurerm_subnet" "web-subnet" {
name = "${var.name}-web-subnet-${var.env}"
virtual_network_name = azurerm_virtual_network.vnet.name
Expand Down
5 changes: 5 additions & 0 deletions ops/terraform/modules/network/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ output "websubnet_id" {
description = "Id of websubnet in the network"
}

output "appgwsubnet_id" {
value = azurerm_subnet.appgw_subnet.id
description = "ID of the appgwsubnet in the network"
}

output "dbsubnet_id" {
value = azurerm_subnet.db-subnet.id
description = "Id of dbsubnet in the network"
Expand Down
1 change: 1 addition & 0 deletions ops/terraform/modules/network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variable "ocrsubnetcidr" {}
variable "env" {}
variable "middlewaresubnetcidr" {}
variable "dbsubnetcidr" {}
variable "appgwsubnetcidr" {}

variable "location" {
default = "eastus2"
Expand Down

0 comments on commit 509a611

Please sign in to comment.