diff --git a/infrastructure/kubernetes/modules/env/main.tf b/infrastructure/kubernetes/modules/env/main.tf index aa15ae2e40..acd3a146ad 100644 --- a/infrastructure/kubernetes/modules/env/main.tf +++ b/infrastructure/kubernetes/modules/env/main.tf @@ -129,7 +129,20 @@ module "k8s_tiler" { { name = "S3_BUCKET_URL" value = var.science_bucket_name - } + }, + { + name = "ROOT_PATH" + value = "" + }, + { + name = "TITILER_PREFIX" + value = "/cog" + }, + { + name = "TITILER_ROUTER_PREFIX" + value = "/cog" + }, + ] } diff --git a/tiler/.env.default b/tiler/.env.default index 4fa88bad8d..cba3177c86 100644 --- a/tiler/.env.default +++ b/tiler/.env.default @@ -2,3 +2,6 @@ REQUIRE_AUTH= API_HOST= S3_BUCKET_URL= +ROOT_PATH= +TITILER_PREFIX= +TITILER_ROUTER_PREFIX= diff --git a/tiler/app/config/config.py b/tiler/app/config/config.py index 85b336e1d0..a4d7d234dd 100644 --- a/tiler/app/config/config.py +++ b/tiler/app/config/config.py @@ -8,7 +8,9 @@ class Settings(BaseSettings): api_port: str = getenv('API_PORT') s3_bucket_url: str = getenv('S3_BUCKET_URL') require_auth: str = getenv('REQUIRE_AUTH') - + root_path: str = getenv("ROOT_PATH") + titiler_prefix: str = getenv("TITILER_PREFIX") + titiler_router_prefix: str = getenv("TITILER_ROUTER_PREFIX") @lru_cache() def get_settings(): diff --git a/tiler/app/main.py b/tiler/app/main.py index 962aa41923..de27a04323 100644 --- a/tiler/app/main.py +++ b/tiler/app/main.py @@ -3,10 +3,16 @@ from titiler.core import TilerFactory from titiler.core.errors import DEFAULT_STATUS_CODES, add_exception_handlers from titiler.core.middleware import TotalTimeMiddleware, LoggerMiddleware + +from .config.config import get_settings from .middlewares.auth_middleware import AuthMiddleware from .middlewares.url_injector import inject_s3_url -app = FastAPI(title="LandGriffon Tiler", root_path="/tiler") +root_path = get_settings().root_path +titiler_router_prefix = get_settings().titiler_router_prefix +titiler_prefix = get_settings().titiler_prefix + +app = FastAPI(title="LandGriffon Tiler", root_path=root_path) app.add_middleware(TotalTimeMiddleware) app.add_middleware(LoggerMiddleware) app.add_middleware(AuthMiddleware) @@ -15,8 +21,8 @@ allow_headers=["*"], ) # single COG tiler. One file can have multiple bands -cog = TilerFactory(router_prefix="/cog", path_dependency=inject_s3_url) -app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"], prefix="/cog", ) +cog = TilerFactory(router_prefix=titiler_router_prefix, path_dependency=inject_s3_url) +app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"], prefix=titiler_prefix) add_exception_handlers(app, DEFAULT_STATUS_CODES)