dotandru commited on
Commit
6fce8f6
·
1 Parent(s): a41344e

fix(deploy): port 8080 via env , bind 0.0.0.0 for Cloud Run

Browse files
Files changed (4) hide show
  1. Dockerfile +3 -3
  2. backend/math_schema.py +6 -5
  3. deploy_dev.ps1 +2 -2
  4. main.py +3 -1
Dockerfile CHANGED
@@ -24,8 +24,8 @@ RUN useradd -m -u 1000 user
24
  USER user
25
  ENV PATH="/home/user/.local/bin:$PATH"
26
 
27
- # חשיפת פורט 7860
28
- EXPOSE 7860
29
 
30
  # --- התיקון הקריטי: הרצה עם uvicorn ---
31
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
24
  USER user
25
  ENV PATH="/home/user/.local/bin:$PATH"
26
 
27
+ # חשיפת פורט 8080 (Cloud Run default)
28
+ EXPOSE 8080
29
 
30
  # --- התיקון הקריטי: הרצה עם uvicorn ---
31
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
backend/math_schema.py CHANGED
@@ -13,7 +13,7 @@ from __future__ import annotations
13
 
14
  from typing import Any, Dict, List, Literal, Optional
15
 
16
- from pydantic import BaseModel, Field
17
 
18
 
19
  class MathProblemSchema(BaseModel):
@@ -22,6 +22,11 @@ class MathProblemSchema(BaseModel):
22
  Flows through: Extractor → Verifier → Pinner → LLM.
23
  """
24
 
 
 
 
 
 
25
  # ── What type of problem ────────────────────────────────────────────
26
  problem_type: Literal[
27
  "geometry",
@@ -83,10 +88,6 @@ class MathProblemSchema(BaseModel):
83
  description="Non-fatal issues: OCR gaps, null substitutions, etc.",
84
  )
85
 
86
- class Config:
87
- # Allow None values in `given` dict (explicit null support)
88
- arbitrary_types_allowed = True
89
-
90
  def null_fields(self) -> List[str]:
91
  """Returns list of keys in `given` that are explicitly null."""
92
  return [k for k, v in self.given.items() if v is None]
 
13
 
14
  from typing import Any, Dict, List, Literal, Optional
15
 
16
+ from pydantic import BaseModel, ConfigDict, Field
17
 
18
 
19
  class MathProblemSchema(BaseModel):
 
22
  Flows through: Extractor → Verifier → Pinner → LLM.
23
  """
24
 
25
+ model_config = ConfigDict(
26
+ # Allow None values in `given` dict (explicit null support)
27
+ arbitrary_types_allowed=True,
28
+ )
29
+
30
  # ── What type of problem ────────────────────────────────────────────
31
  problem_type: Literal[
32
  "geometry",
 
88
  description="Non-fatal issues: OCR gaps, null substitutions, etc.",
89
  )
90
 
 
 
 
 
91
  def null_fields(self) -> List[str]:
92
  """Returns list of keys in `given` that are explicitly null."""
93
  return [k for k, v in self.given.items() if v is None]
deploy_dev.ps1 CHANGED
@@ -18,9 +18,9 @@ gcloud config set project $PROJECT_ID
18
  Write-Host "Building Image..."
19
  gcloud builds submit --tag $IMAGE_NAME .
20
 
21
- # 4. Deploy to Cloud Run (Single Line Command to avoid Backtick errors)
22
  Write-Host "Deploying to Cloud Run..."
23
- gcloud run deploy $SERVICE_NAME --image $IMAGE_NAME --platform managed --region $REGION --allow-unauthenticated --set-env-vars "ENV=development,OCR_STRIP_MODE=development"
24
 
25
  Write-Host "Deployment Complete!" -ForegroundColor Green
26
 
 
18
  Write-Host "Building Image..."
19
  gcloud builds submit --tag $IMAGE_NAME .
20
 
21
+ # 4. Deploy to Cloud Run (Including Secrets & 60s Timeout)
22
  Write-Host "Deploying to Cloud Run..."
23
+ gcloud run deploy $SERVICE_NAME --image $IMAGE_NAME --platform managed --region $REGION --allow-unauthenticated --set-env-vars "ENV=development,OCR_STRIP_MODE=development" --set-secrets "GOOGLE_API_KEY=GOOGLE_API_KEY:latest,FIREBASE_CREDENTIALS=FIREBASE_CREDENTIALS:latest" --timeout 60
24
 
25
  Write-Host "Deployment Complete!" -ForegroundColor Green
26
 
main.py CHANGED
@@ -826,5 +826,7 @@ async def send_weekly_report(req: ReportRequest):
826
  return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
827
 
828
  if __name__ == "__main__":
 
829
  import uvicorn
830
- uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
 
 
826
  return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
827
 
828
  if __name__ == "__main__":
829
+ import os
830
  import uvicorn
831
+ port = int(os.environ.get("PORT", 8080))
832
+ uvicorn.run("main:app", host="0.0.0.0", port=port)