This commit is contained in:
johnpccd 2025-05-24 23:00:51 +02:00
parent 9814c334e5
commit 12613c156e
7 changed files with 19 additions and 1333 deletions

View File

@ -1,77 +0,0 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: sereact
annotations:
run.googleapis.com/ingress: all
spec:
template:
metadata:
annotations:
run.googleapis.com/ingress: all
spec:
containers:
- image: gcr.io/gen-lang-client-0424120530/sereact-api:latest
ports:
- containerPort: 8000
resources:
limits:
cpu: "1"
memory: "1Gi"
env:
- name: FIRESTORE_PROJECT_ID
value: "gen-lang-client-0424120530"
- name: FIRESTORE_CREDENTIALS_FILE
value: "/var/secrets/google/key.json"
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/var/secrets/google/key.json"
- name: GCS_BUCKET_NAME
value: "gen-lang-client-0424120530-images"
- name: API_KEY_SECRET
valueFrom:
secretKeyRef:
name: sereact-api-key-secret
key: latest
- name: VECTOR_DB_API_KEY
valueFrom:
secretKeyRef:
name: sereact-vector-db-key
key: latest
- name: VECTOR_DB_ENVIRONMENT
value: "gcp-starter"
- name: VECTOR_DB_INDEX_NAME
value: "image-embeddings"
- name: LOG_LEVEL
value: "INFO"
- name: CORS_ORIGINS
value: "['*']"
- name: CORS_METHODS
value: "GET,POST,PUT,DELETE,OPTIONS"
- name: CORS_HEADERS
value: "Content-Type,Authorization,X-Requested-With"
- name: CORS_EXPOSE_HEADERS
value: "Content-Length,Content-Range"
- name: CORS_MAX_AGE
value: "3600"
- name: QDRANT_HTTPS
value: "false"
- name: QDRANT_PREFER_GRPC
value: "false"
volumeMounts:
- name: gcp-sa-key
mountPath: /var/secrets/google
readOnly: true
startupProbe:
httpGet:
path: /
port: 8000
initialDelaySeconds: 20
periodSeconds: 5
failureThreshold: 10
volumes:
- name: gcp-sa-key
secret:
secretName: sereact-gcp-sa-key
items:
- key: latest
path: key.json

View File

@ -1,53 +0,0 @@
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA', '.']
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA']
# Tag the image as latest
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA', 'gcr.io/$PROJECT_ID/sereact-api:latest']
# Push the latest tag
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/sereact-api:latest']
# Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'sereact'
- '--image=gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA'
- '--region=us-central1'
- '--platform=managed'
- '--allow-unauthenticated'
- '--set-env-vars=GCS_BUCKET_NAME=${_GCS_BUCKET_NAME},FIRESTORE_PROJECT_ID=${PROJECT_ID},VECTOR_DB_ENVIRONMENT=${_VECTOR_DB_ENVIRONMENT},VECTOR_DB_INDEX_NAME=${_VECTOR_DB_INDEX_NAME},LOG_LEVEL=INFO'
- '--set-secrets=API_KEY_SECRET=sereact-api-key-secret:latest,VECTOR_DB_API_KEY=sereact-vector-db-key:latest'
# Optional: Run tests after deployment
# - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
# entrypoint: /bin/bash
# args:
# - '-c'
# - |
# SERVICE_URL=$(gcloud run services describe sereact --region=us-central1 --format='value(status.url)')
# curl -s -o /dev/null -w "%{http_code}" $${SERVICE_URL}/health | grep 200
# Store images in Container Registry
images:
- 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/sereact-api:latest'
# Substitution variables to be set in the Cloud Build trigger
substitutions:
_GCS_BUCKET_NAME: 'your-app-storage-bucket'
_VECTOR_DB_ENVIRONMENT: 'your-pinecone-env'
_VECTOR_DB_INDEX_NAME: 'image-embeddings'
# Increase timeout to 30 minutes
timeout: '1800s'

View File

@ -1 +0,0 @@
{"ID":"5f252024-676f-4920-f829-cb47c30360a4","Operation":"OperationTypeApply","Info":"","Who":"DESKTOP\\habal@Desktop","Version":"1.10.1","Created":"2025-05-24T20:52:18.4005055Z","Path":"terraform.tfstate"}

View File

@ -133,7 +133,7 @@ resource "google_cloud_run_service" "sereact" {
# CORS Configuration - These were missing!
env {
name = "CORS_ORIGINS"
value = "['*']"
value = "*"
}
env {

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"version": 4,
"terraform_version": "1.10.1",
"serial": 268,
"serial": 273,
"lineage": "a183cd95-f987-8698-c6dd-84e933c394a5",
"outputs": {
"cloud_run_qdrant_host": {
@ -136,7 +136,7 @@
"effective_annotations": {
"run.googleapis.com/ingress": "all",
"run.googleapis.com/ingress-status": "all",
"run.googleapis.com/operation-id": "25c8aa08-3810-4d26-82c7-5fa64300fdf9",
"run.googleapis.com/operation-id": "8e5e22cf-c77d-4cb8-8587-5cf9d409193c",
"run.googleapis.com/urls": "[\"https://sereact-761163285547.us-central1.run.app\",\"https://sereact-p64zpdtkta-uc.a.run.app\"]",
"serving.knative.dev/creator": "johnpccd3@gmail.com",
"serving.knative.dev/lastModifier": "johnpccd3@gmail.com"
@ -145,10 +145,10 @@
"cloud.googleapis.com/location": "us-central1",
"goog-terraform-provisioned": "true"
},
"generation": 3,
"generation": 5,
"labels": {},
"namespace": "gen-lang-client-0424120530",
"resource_version": "AAY15dY3+48",
"resource_version": "AAY15+pAZzs",
"self_link": "/apis/serving.knative.dev/v1/namespaces/761163285547/services/sereact",
"terraform_labels": {
"goog-terraform-provisioned": "true"
@ -162,27 +162,27 @@
{
"conditions": [
{
"message": "Revision 'sereact-00003-2fs' is not ready and cannot serve traffic. The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00003-2fs\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00003-2fs%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"message": "Revision 'sereact-00005-5n6' is not ready and cannot serve traffic. The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00005-5n6\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00005-5n6%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"reason": "HealthCheckContainerError",
"status": "False",
"type": "Ready"
},
{
"message": "The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00003-2fs\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00003-2fs%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"message": "The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00005-5n6\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00005-5n6%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"reason": "",
"status": "True",
"type": "ConfigurationsReady"
},
{
"message": "Revision 'sereact-00003-2fs' is not ready and cannot serve traffic. The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00003-2fs\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00003-2fs%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"message": "Revision 'sereact-00005-5n6' is not ready and cannot serve traffic. The user-provided container failed the configured startup probe checks. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=gen-lang-client-0424120530\u0026resource=cloud_run_revision/service_name/sereact/revision_name/sereact-00005-5n6\u0026advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22sereact%22%0Aresource.labels.revision_name%3D%22sereact-00005-5n6%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
"reason": "HealthCheckContainerError",
"status": "False",
"type": "RoutesReady"
}
],
"latest_created_revision_name": "sereact-00003-2fs",
"latest_created_revision_name": "sereact-00005-5n6",
"latest_ready_revision_name": "sereact-00001-rsq",
"observed_generation": 3,
"observed_generation": 5,
"traffic": [
{
"latest_revision": true,
@ -243,7 +243,7 @@
},
{
"name": "CORS_ORIGINS",
"value": "['*']",
"value": "*",
"value_from": []
},
{
@ -444,13 +444,6 @@
}
]
},
{
"mode": "managed",
"type": "google_compute_address",
"name": "vector_db_static_ip",
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
"instances": []
},
{
"mode": "managed",
"type": "google_compute_firewall",
@ -723,8 +716,8 @@
"database_edition": "STANDARD",
"delete_protection_state": "DELETE_PROTECTION_DISABLED",
"deletion_policy": "ABANDON",
"earliest_version_time": "2025-05-24T19:50:07.050995Z",
"etag": "IKWD/+D9vI0DMLa2lbPIvI0D",
"earliest_version_time": "2025-05-24T19:55:31.455016Z",
"etag": "IM+J1/v+vI0DMLa2lbPIvI0D",
"id": "projects/gen-lang-client-0424120530/databases/sereact-imagedb",
"key_prefix": "",
"location_id": "us-central1",

View File

@ -23,6 +23,9 @@ class Settings(BaseSettings):
# Read from environment variable first
env_origins = os.getenv("CORS_ORIGINS")
if env_origins:
# Handle wildcard case
if env_origins.strip() == "*":
return ["*"]
if env_origins.startswith("[") and env_origins.endswith("]"):
# Handle list format like "['*']"
import ast