diff --git a/.github/workflows/continuous_delivery.yaml b/.github/workflows/continuous_delivery.yaml index a241ed2..e2f9062 100644 --- a/.github/workflows/continuous_delivery.yaml +++ b/.github/workflows/continuous_delivery.yaml @@ -2,7 +2,7 @@ name: Continuous Delivery on: workflow_run: - workflows: ["Continous Delivery (Infrastructure)", "Continuous Integration"] + workflows: ["Continuous Integration", "Continous Delivery (Infrastructure)"] types: - completed workflow_dispatch: @@ -10,8 +10,9 @@ on: jobs: release: if: | - github.event.workflow_run.conclusion == 'success' - && github.event.workflow_run.head_branch == 'main' + github.event.workflow_run.conclusion == 'success' && + contains(fromJson('["Continuous Integration", "Continous Delivery (Infrastructure)"]'), github.event.workflow_run.name) && + github.event.workflow_run.event == 'push' name: Create GitHub Release runs-on: ubuntu-24.04 concurrency: release @@ -36,8 +37,9 @@ jobs: runs-on: ubuntu-24.04 needs: release if: | - github.event.workflow_run.conclusion == 'success' - && github.event.workflow_run.head_branch == 'main' + github.event.workflow_run.conclusion == 'success' && + contains(fromJson('["Continuous Integration", "Continous Delivery (Infrastructure)"]'), github.event.workflow_run.name) && + github.event.workflow_run.event == 'push' steps: - name: Checkout code diff --git a/.github/workflows/update_infrastructure.yaml b/.github/workflows/update_infrastructure.yaml index 4abba66..ce9362c 100644 --- a/.github/workflows/update_infrastructure.yaml +++ b/.github/workflows/update_infrastructure.yaml @@ -27,11 +27,11 @@ jobs: - name: Setup terraform.tfvars run: | cat < terraform.tfvars - db_password = "${{ secrets.DB_PASSWORD }}" project_id = "${{ secrets.TF_PROJECT_ID }}" terraform_sa_email = "${{ secrets.TF_SA_EMAIL }}" cloud_run_env_vars = { + DATABASE_URL = "${{ secrets.DATABASE_URL }}" ENV = "production" OPENAI_API_KEY = "${{ secrets.OPENAI_API_KEY_PROD }}" } diff --git a/.vscode/settings.json b/.vscode/settings.json index b301d46..da53936 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,6 +57,5 @@ "username": "postgres", "password": "password" } - ], - "windsurfPyright.disableLanguageServices": true + ] } diff --git a/terraform/cloud_run.tf b/terraform/cloud_run.tf index d45a8fd..94038c8 100644 --- a/terraform/cloud_run.tf +++ b/terraform/cloud_run.tf @@ -8,14 +8,6 @@ resource "google_cloud_run_service" "fastapi" { location = var.region project = var.project_id - metadata { - annotations = { - "run.googleapis.com/cloudsql-instances" = google_sql_database_instance.sql_instance_sightcall_qa_api.connection_name - "run.googleapis.com/vpc-access-connector" = google_vpc_access_connector.serverless_connector.id - "run.googleapis.com/vpc-access-egress" = "all-traffic" - } - } - template { spec { service_account_name = google_service_account.cloudrun_sa.email @@ -34,11 +26,6 @@ resource "google_cloud_run_service" "fastapi" { value = env.value } } - - env { - name = "DATABASE_URL" - value = local.database_url - } } } diff --git a/terraform/database.tf b/terraform/database.tf deleted file mode 100644 index 526e307..0000000 --- a/terraform/database.tf +++ /dev/null @@ -1,32 +0,0 @@ -resource "google_sql_database_instance" "sql_instance_sightcall_qa_api" { - name = "sightcall-qa-api-db" - region = var.region - database_version = "POSTGRES_17" - - settings { - tier = "db-g1-small" - - ip_configuration { - ipv4_enabled = false - private_network = google_compute_network.app_network.self_link - } - - database_flags { - name = "cloudsql.enable_pgvector" - value = "on" - } - } - - deletion_protection = false -} - -resource "google_sql_database" "vectordb" { - name = "sightcall_qa_api_vectordb" - instance = google_sql_database_instance.sql_instance_sightcall_qa_api.name -} - -resource "google_sql_user" "db_user" { - name = "sightcall_qa_api_user" - instance = google_sql_database_instance.sql_instance_sightcall_qa_api.name - password_wo = var.db_password -} diff --git a/terraform/locals.tf b/terraform/locals.tf deleted file mode 100644 index a1fc8cb..0000000 --- a/terraform/locals.tf +++ /dev/null @@ -1,9 +0,0 @@ -locals { - database_url = format( - "postgresql://%s:%s@/%s?host=/cloudsql/%s", - google_sql_user.db_user.name, - var.db_password, - google_sql_database.vectordb.name, - google_sql_database_instance.sql_instance_sightcall_qa_api.connection_name - ) -} diff --git a/terraform/terraform.tfvars.example b/terraform/terraform.tfvars.example index 45a2af7..89d91ba 100644 --- a/terraform/terraform.tfvars.example +++ b/terraform/terraform.tfvars.example @@ -1,8 +1,8 @@ -db_password = "password" project_id = "sightcall-qa-api" terraform_sa_email = "terraform@example.iam.gserviceaccount.com" cloud_run_env_vars = { + DATABASE_URL = "postgresql://postgres:password@vector_db:5432/vectordb" ENV = "production" OPENAI_API_KEY = "sk-" } \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index 7f3065e..7b366a0 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -9,12 +9,6 @@ variable "cloud_run_env_vars" { default = {} } -variable "db_password" { - type = string - description = "Password for the database" - sensitive = true -} - variable "enabled_apis" { type = list(string) default = [ @@ -26,8 +20,7 @@ variable "enabled_apis" { "iam.googleapis.com", "serviceusage.googleapis.com", "logging.googleapis.com", - "monitoring.googleapis.com", - "vpcaccess.googleapis.com" + "monitoring.googleapis.com" ] } diff --git a/terraform/vpc.tf b/terraform/vpc.tf deleted file mode 100644 index f821634..0000000 --- a/terraform/vpc.tf +++ /dev/null @@ -1,22 +0,0 @@ -resource "google_compute_network" "app_network" { - name = "sightcall-qa-api-network" - auto_create_subnetworks = false -} - -resource "google_compute_subnetwork" "app_subnet" { - name = "sightcall-qa-api-subnet" - ip_cidr_range = "10.8.0.0/28" - region = var.region - network = google_compute_network.app_network.id -} - -resource "google_vpc_access_connector" "serverless_connector" { - name = "sightcall-qa-api-serverless-connector" - region = var.region - network = google_compute_network.app_network.name - ip_cidr_range = "10.8.0.0/28" - - lifecycle { - create_before_destroy = true - } -} \ No newline at end of file