Skip to content

Commit b69a779

Browse files
authored
Merge pull request #159 from developmentseed/feat/stac-browser-tiler
- add stac browser to docker deployment - make use of radiant earth browser config to have control over which tiler is used - create a separate settings object for the browser for readability
2 parents 3437f85 + 1997b48 commit b69a779

File tree

8 files changed

+158
-11
lines changed

8 files changed

+158
-11
lines changed

docker-compose.custom.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
version: '3'
22

33
services:
4+
stac-browser:
5+
profiles:
6+
- gunicorn
7+
build:
8+
context: dockerfiles
9+
dockerfile: Dockerfile.browser
10+
ports:
11+
- "${MY_DOCKER_IP:-127.0.0.1}:8085:8085"
12+
depends_on:
13+
- stac
14+
- database
15+
- raster
416
stac:
517
container_name: eoapi.stac
618
profiles:

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
version: '3'
22

33
services:
4+
5+
# change to official image when available https://github.com/radiantearth/stac-browser/pull/386
6+
stac-browser:
7+
build:
8+
context: dockerfiles
9+
dockerfile: Dockerfile.browser
10+
ports:
11+
- "${MY_DOCKER_IP:-127.0.0.1}:8085:8085"
12+
depends_on:
13+
- stac-fastapi
14+
- titiler-pgstac
15+
- database
16+
417
stac-fastapi:
518
# Note:
619
# the official ghcr.io/stac-utils/stac-fastapi-pgstac image uses python 3.8 and uvicorn

dockerfiles/Dockerfile.browser

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright Radiant Earth Foundation
2+
3+
FROM node:lts-alpine3.18 AS build-step
4+
ARG DYNAMIC_CONFIG=true
5+
6+
WORKDIR /app
7+
8+
RUN apk add --no-cache git
9+
RUN git clone https://github.com/radiantearth/stac-browser.git .
10+
# remove the default config.js
11+
RUN rm config.js
12+
RUN npm install
13+
# replace the default config.js with our config file
14+
COPY ./browser_config.js ./config.js
15+
RUN \[ "${DYNAMIC_CONFIG}" == "true" \] && sed -i 's/<!-- <script defer="defer" src=".\/config.js"><\/script> -->/<script defer="defer" src=".\/config.js"><\/script>/g' public/index.html
16+
RUN npm run build
17+
18+
19+
FROM nginx:1-alpine-slim
20+
21+
COPY --from=build-step /app/dist /usr/share/nginx/html
22+
COPY --from=build-step /app/config.schema.json /etc/nginx/conf.d/config.schema.json
23+
24+
# change default port to 8084
25+
RUN apk add jq pcre-tools && \
26+
sed -i 's/\s*listen\s*80;/ listen 8084;/' /etc/nginx/conf.d/default.conf && \
27+
sed -i 's/\s*location \/ {/ location \/ {\n try_files $uri $uri\/ \/index.html;/' /etc/nginx/conf.d/default.conf
28+
29+
EXPOSE 8084
30+
31+
STOPSIGNAL SIGTERM
32+
33+
# override entrypoint, which calls nginx-entrypoint underneath
34+
COPY --from=build-step /app/docker/docker-entrypoint.sh ./docker-entrypoint.d/40-stac-browser-entrypoint.sh

dockerfiles/browser_config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
catalogUrl: "http://0.0.0.0:8081",
3+
catalogTitle: "eoAPI STAC Browser",
4+
allowExternalAccess: true, // Must be true if catalogUrl is not given
5+
allowedDomains: [],
6+
detectLocaleFromBrowser: true,
7+
storeLocale: true,
8+
locale: "en",
9+
fallbackLocale: "en",
10+
supportedLocales: [
11+
"de",
12+
"es",
13+
"en",
14+
"fr",
15+
"it",
16+
"ro"
17+
],
18+
apiCatalogPriority: null,
19+
useTileLayerAsFallback: true,
20+
displayGeoTiffByDefault: false,
21+
buildTileUrlTemplate: ({href, asset}) => "http://0.0.0.0:8082/cog/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
22+
stacProxyUrl: null,
23+
pathPrefix: "/",
24+
historyMode: "history",
25+
cardViewMode: "cards",
26+
cardViewSort: "asc",
27+
showThumbnailsAsAssets: false,
28+
stacLint: true,
29+
geoTiffResolution: 128,
30+
redirectLegacyUrls: false,
31+
itemsPerPage: 12,
32+
defaultThumbnailSize: null,
33+
maxPreviewsOnMap: 50,
34+
crossOriginMedia: null,
35+
requestHeaders: {},
36+
requestQueryParameters: {},
37+
preprocessSTAC: null,
38+
authConfig: null
39+
};

infrastructure/aws/cdk/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
eoAPISettings,
1717
eoDBSettings,
1818
eoRasterSettings,
19+
eoStacBrowserSettings,
1920
eoSTACSettings,
2021
eoVectorSettings,
2122
)
@@ -242,10 +243,9 @@ def __init__( # noqa: C901
242243
},
243244
)
244245

245-
if eostac_settings.stac_api_custom_domain_name is not None:
246-
assert (
247-
eostac_settings.stac_browser_github_tag is not None
248-
), "stac_browser_github_tag must be set if stac_api_custom_domain_name is not None."
246+
if "browser" in eoapi_settings.functions:
247+
eobrowser_settings = eoStacBrowserSettings()
248+
249249
stac_browser_bucket = s3.Bucket(
250250
self,
251251
"stac-browser-bucket",
@@ -268,10 +268,11 @@ def __init__( # noqa: C901
268268
StacBrowser(
269269
self,
270270
"stac-browser",
271-
github_repo_tag=eostac_settings.stac_browser_github_tag,
272-
stac_catalog_url=eostac_settings.stac_api_custom_domain_name,
271+
github_repo_tag=eobrowser_settings.stac_browser_github_tag,
272+
stac_catalog_url=eobrowser_settings.stac_catalog_url,
273273
website_index_document="index.html",
274274
bucket_arn=stac_browser_bucket.bucket_arn,
275+
config_file_path=eobrowser_settings.config_file_path,
275276
)
276277

277278
# eoapi.vector
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
catalogUrl: null,
3+
catalogTitle: "eoAPI STAC Browser",
4+
allowExternalAccess: true, // Must be true if catalogUrl is not given
5+
allowedDomains: [],
6+
detectLocaleFromBrowser: true,
7+
storeLocale: true,
8+
locale: "en",
9+
fallbackLocale: "en",
10+
supportedLocales: [
11+
"de",
12+
"es",
13+
"en",
14+
"fr",
15+
"it",
16+
"ro"
17+
],
18+
apiCatalogPriority: null,
19+
useTileLayerAsFallback: true,
20+
displayGeoTiffByDefault: false,
21+
buildTileUrlTemplate: ({href, asset}) => "https://raster.dev/cog/tiles/{z}/{x}/{y}@2x?url=" + encodeURIComponent(asset.href.startsWith("/vsi") ? asset.href : href),
22+
stacProxyUrl: null,
23+
pathPrefix: "/",
24+
historyMode: "history",
25+
cardViewMode: "cards",
26+
cardViewSort: "asc",
27+
showThumbnailsAsAssets: false,
28+
stacLint: true,
29+
geoTiffResolution: 128,
30+
redirectLegacyUrls: false,
31+
itemsPerPage: 12,
32+
defaultThumbnailSize: null,
33+
maxPreviewsOnMap: 50,
34+
crossOriginMedia: null,
35+
requestHeaders: {},
36+
requestQueryParameters: {},
37+
preprocessSTAC: null,
38+
authConfig: null
39+
};

infrastructure/aws/cdk/config.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class functionName(str, Enum):
1313
raster = "raster"
1414
vector = "vector"
1515
ingestor = "ingestor"
16+
browser = "browser" # not actually a function, but this keeps things clean.
1617

1718

1819
class eoAPISettings(BaseSettings):
@@ -57,10 +58,6 @@ class eoSTACSettings(BaseSettings):
5758

5859
timeout: int = 10
5960
memory: int = 256
60-
stac_browser_github_tag: None | str = "v3.1.0"
61-
stac_api_custom_domain_name: None | str = (
62-
None # if not none, will try to deploy a browser with the above tag
63-
)
6461
model_config = {
6562
"env_prefix": "CDK_EOAPI_STAC_",
6663
"env_file": ".env",
@@ -115,3 +112,15 @@ class eoVectorSettings(BaseSettings):
115112
"env_prefix": "CDK_EOAPI_VECTOR_",
116113
"env_file": ".env",
117114
}
115+
116+
117+
class eoStacBrowserSettings(BaseSettings):
118+
"""STAC browser settings"""
119+
120+
stac_browser_github_tag: None | str = "v3.1.0"
121+
stac_catalog_url: None | str = None
122+
config_file_path: None | str = None
123+
model_config = {
124+
"env_prefix": "CDK_EOAPI_BROWSER_",
125+
"env_file": ".env",
126+
}

infrastructure/aws/requirements-cdk.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ boto3==1.28.71
77
# pydantic settings
88
pydantic~=2.0
99
pydantic-settings~=2.0
10-
eoapi-cdk==6.0.0
10+
eoapi-cdk==6.1.0

0 commit comments

Comments
 (0)