Skip to content

Commit

Permalink
Test deploy middleware (#479)
Browse files Browse the repository at this point in the history
* deploy middleware to demo env

* wip

* wip

* change image

* added default paramaters to dev file

* added default values for dev-env file

* formatting

* added bash exp synthax

* updates to db, vault and networking

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* add output variables for db password, username, db name to middleware_api

* remove commented out code and update middleware-api or app_service module with variables

* minor updates

* update app_settings in the middleware

* removed unused variables

* conatiner change

* expose to 8081

* rm continuous

* amd64

* add expose fro port 80 in dockerfile

* go back to port 8080 and rm the port flag in the cmd

* wip

* add new app setting vars

* deploy middleware to dev

* deploy middleware to dev

* deploy middleware to dev

* deploy middleware to dev

* push new var to frontend

* push new var to frontend

* push new var to frontend

* push new var to frontend

* push new var to frontend

* wip

* clean

* deploy to middleware with CORS change

* deploy to middleware with CORS change

* deploy front to dev

* wip

* wip

* wip

* clean

* push

---------

Co-authored-by: Administrator <[email protected]>
Co-authored-by: Arindam Kulshi <[email protected]>
Co-authored-by: marycrawford <[email protected]>
  • Loading branch information
4 people authored Dec 13, 2024
1 parent c75061f commit 8164f48
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-frontend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
shell: bash
working-directory: ${{ inputs.frontend-path }}
run: |
VITE_API_URL=${{ inputs.api-endpoint }} npm run build
VITE_MIDDLEWARE_API_URL=${{ inputs.api-endpoint }} npm run build
- name: Test frontend
shell: bash
working-directory: ${{ inputs.frontend-path }}
Expand Down
1 change: 1 addition & 0 deletions .github/actions/build-publish-api/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ runs:
context: ${{ inputs.docker-context-path }}
file: ${{ inputs.dockerfile-path }}
push: true
platforms: linux/amd64
tags: ${{ inputs.docker-registry }}/${{ env.REPO }}-${{ inputs.api-name }}:${{ inputs.docker-tag }}
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: ./.github/actions/build-frontend
name: Build frontend
with:
api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net
api-endpoint: https://reportvision-middleware-${{ inputs.deploy-env }}.azurewebsites.net/
frontend-tarball: ./frontend.tgz
frontend-path: ./frontend
frontend-build-path: ./frontend/dist/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-ocr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:
deploy-env: ${{ inputs.deploy-env }}
docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }}
docker-registry: ghcr.io
api-name: ocr
api-name: ocr
18 changes: 14 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
FROM amazoncorretto:17
ENV HOME=/app
RUN mkdir -p $HOME
WORKDIR $HOME
# Use a base image with Java and Gradle
FROM openjdk:17-slim

# Set the working directory
WORKDIR /app

# Copy the project files
COPY . .

RUN chmod +x ./gradlew

EXPOSE 8080

ENTRYPOINT [ "./gradlew", "bootRun" ]
2 changes: 1 addition & 1 deletion backend/dev-dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM amazoncorretto:17
ENV HOME=/app
RUN mkdir -p $HOME
WORKDIR $HOME
ENTRYPOINT [ "./gradlew", "bootRun", "--continuous", "--args=--server.port=8081" ]
ENTRYPOINT [ "./gradlew", "bootRun", "--continuous", "--args=--server.port=8081" ]
2 changes: 0 additions & 2 deletions dev-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ services:
restart: "unless-stopped"
depends_on:
- db
command: "./gradlew bootRun --continuous --args='--server.port=8081'"

13 changes: 9 additions & 4 deletions ops/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ module "middleware_api" {
app_subnet_id = module.networking.middlewaresubnet_id

app_settings = {
WEBSITES_PORT = "8081"
WEBSITES_PORT = "8080"
PORT = "8080"
SSL_MODE = "require"
POSTGRES_HOST = module.database.postgres_fqdn
POSTGRES_DB = module.database.postgres_db_name
POSTGRES_DB = "${module.database.postgres_db_name}-db"
POSTGRES_USER = module.database.postgres_user
POSTGRES_PASSWORD = module.vault.postgres_password
WEBSITES_CONTAINER_START_TIME_LIMIT = 400
FASTAPI_URL = "https://${module.ocr_api.app_hostname}"
DEBUG = true
}

lb_subnet_id = module.networking.lbsubnet_id
Expand All @@ -102,12 +107,12 @@ module "ocr_api" {
WEBSITES_PORT = "8000"
}

lb_subnet_id = module.networking.middlewaresubnet_id
lb_subnet_id = module.networking.lbsubnet_id
env = local.environment
vnet = module.networking.network_name
sku_name = var.sku_name
https_only = true
depends_on = [module.networking.ocrsubnet_id, module.networking.middlewaresubnet_id]
depends_on = [module.networking.ocrsubnet_id, module.networking.lbsubnet_id]
}

module "ocr_autoscale" {
Expand Down
7 changes: 1 addition & 6 deletions ops/terraform/modules/app_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ resource "azurerm_linux_web_app" "linux_webapp" {
scm_minimum_tls_version = "1.2"
use_32_bit_worker = false
ftps_state = "Disabled"
vnet_route_all_enabled = false

ip_restriction {
virtual_network_subnet_id = var.lb_subnet_id
action = "Allow"
}
vnet_route_all_enabled = true
}
}
2 changes: 1 addition & 1 deletion ops/terraform/modules/app_service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variable "env" {}
variable "name" {}
variable "resource_group" {}
variable "location" {}
variable "lb_subnet_id" {}

variable "app_subnet_id" {}
variable "sku_name" {
default = "S2"
Expand Down
2 changes: 1 addition & 1 deletion ops/terraform/modules/database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "azurerm_postgresql_flexible_server" "postgres_flexible_server" {
public_network_access_enabled = false

lifecycle {
prevent_destroy = false
prevent_destroy = true
ignore_changes = [zone]
}
}
Expand Down
6 changes: 0 additions & 6 deletions ops/terraform/modules/security/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ resource "azurerm_network_security_group" "web-nsg" {
# }
}

resource "azurerm_subnet_network_security_group_association" "web-nsg-subnet" {
depends_on = [azurerm_network_security_rule.ag_nsg_rule_inbound]
subnet_id = var.lb_subnet_id
network_security_group_id = azurerm_network_security_group.web-nsg.id
}

locals {
ag_inbound_ports_map = {
"100" : "80", # If the key starts with a number, you must use the colon syntax ":" instead of "="
Expand Down
3 changes: 1 addition & 2 deletions ops/terraform/modules/vault/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ variable "object_id" {
type = string
}
variable "postgres_server_id" {
type = string
}
variable "resource_group_name" {}
variable "subscription_id" {}
variable "service_plan_id" {}
variable "tenant_id" {}
variable "tenant_id" {}

0 comments on commit 8164f48

Please sign in to comment.