Skip to content

Commit

Permalink
setup for attach to running docker (since our weird silent CORs bug a…
Browse files Browse the repository at this point in the history
…ppears to only occur in the actual deployment)
  • Loading branch information
GondekNP committed Aug 5, 2024
1 parent 87781ca commit 30fea75
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,36 @@
"envFile": "/workspace/.devcontainer/.env",
"python": "/opt/conda/envs/titiler-prod/bin/python",
"console": "integratedTerminal"
},
{
"name": "Python: Attach to Docker Burn Backend",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/workspace/src/burn_backend"
}
]
},
{
"name": "Python: Attach to Docker TiTiler",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/workspace/src/titiler"
}
]
}
]
}
13 changes: 11 additions & 2 deletions src/burn_backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
## APP SETUP ##
app = FastAPI(docs_url="/documentation")

## CORS ##

## CORS / LOCAL DEV ##
if os.getenv("ENV") == "LOCAL":
# Set up CORS for local development
allowed_origins = [os.getenv("LOCAL_ENDPOINT_TITILER", "http://localhost:8081")]

# Set up debugpy
import debugpy

debugpy.listen(("0.0.0.0", 5678))
print("Waiting for debugger attach...")
debugpy.wait_for_client()
print("Debugger attached")

else:
allowed_origins = [os.getenv("GCP_CLOUD_RUN_ENDPOINT_TITILER")]

Expand Down
12 changes: 12 additions & 0 deletions src/titiler/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles

Expand All @@ -7,6 +9,16 @@
from src.titiler.lib.titiler_algorithms import algorithms
from src.titiler.routers.pages import home, map, upload, directory

## LOCAL DEV ##
if os.getenv("ENV") == "LOCAL":
# Set up debugpy
import debugpy

debugpy.listen(("0.0.0.0", 5678))
print("Waiting for debugger attach...")
debugpy.wait_for_client()
print("Debugger attached")

## APP SETUP ##
app = FastAPI(docs_url="/documentation")
app.mount("/static", StaticFiles(directory="src/titiler/static"), name="static")
Expand Down

0 comments on commit 30fea75

Please sign in to comment.