Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

feat(docker): runtime config for demo-app image (#3725)

Igor Dykhtaf9a29942a190
diff --git a/.dockerignore b/.dockerignore
index b6d87a6ec..b9f492ad7 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -26,6 +26,12 @@
.conda
.netlify
+# Secrets must not be baked into publishable images (use runtime /config.json)
+.env
+.env.*
+!.env.template
+docker/config.json
+
# Not used by the demo-app image
bindings
website
@@ -35,7 +41,12 @@ screenshots
skill
contributing
typedoc
-docker
+
+# Compose/docs/Dockerfiles are read by the CLI, not needed inside the build context
+docker/docker-compose.yml
+docker/Dockerfile
+docker/Dockerfile.dev
+docker/README.md
# Other examples (keep demo-app only)
examples/*
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 000000000..015e260d8
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,71 @@
+# Prod image smoke test (env-only /config.json). Skipped unless docker packaging changes.
+name: Docker CI
+
+on:
+ push:
+ branches: [master]
+ paths:
+ - 'docker/**'
+ - '.dockerignore'
+ - '.github/workflows/docker.yml'
+ pull_request:
+ branches: [master]
+ paths:
+ - 'docker/**'
+ - '.dockerignore'
+ - '.github/workflows/docker.yml'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+ kepler-prod:
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+ permissions:
+ contents: read
+ actions: write
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Validate Compose file
+ run: |
+ printf 'MapboxAccessToken=pk.ci-test\nKEPLER_PAGE_TITLE=ci-title\n' > .env
+ docker compose -f docker/docker-compose.yml --env-file .env config >/dev/null
+
+ - name: Build production image
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ file: docker/Dockerfile
+ load: true
+ provenance: false
+ sbom: false
+ tags: kepler-prod:ci
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Smoke-test runtime config
+ run: |
+ docker run -d --name kepler-prod -p 8080:8080 \
+ -e KEPLER_MAPBOX_ACCESS_TOKEN=pk.ci-test \
+ -e KEPLER_PAGE_TITLE=ci-title \
+ kepler-prod:ci
+
+ cleanup() { docker logs kepler-prod || true; docker rm -f kepler-prod || true; }
+ trap cleanup EXIT
+
+ for _ in $(seq 1 30); do
+ if curl -fsS http://127.0.0.1:8080/config.json >/dev/null; then
+ break
+ fi
+ sleep 2
+ done
+
+ curl -fsS http://127.0.0.1:8080/config.json > /tmp/kepler-config.json
+ python3 -c 'import json; c=json.load(open("/tmp/kepler-config.json")); assert c["credentials"]["MapboxAccessToken"]=="pk.ci-test", c; assert c["pageTitle"]=="ci-title", c'
+ curl -fsS http://127.0.0.1:8080/ | grep -q 'id="root"'
diff --git a/.gitignore b/.gitignore
index e6a56f1fa..29c8a4959 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,3 +55,4 @@ lerna-debug.log
.netlify
meta.json
.env
+docker/config.json
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 5b9ef5e53..22a783ba1 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -31,6 +31,7 @@ WORKDIR /app/examples/demo-app
RUN --mount=type=cache,id=kepler-yarn,target=/yarn-cache \
YARN_CACHE_FOLDER=/yarn-cache yarn install
+# Build without secrets — tokens are injected at runtime via /config.json or KEPLER_* env
RUN yarn build
FROM node:20-alpine AS runtime
@@ -40,7 +41,11 @@ WORKDIR /app
RUN npm install -g serve@14
COPY --from=builder /app/examples/demo-app/dist ./dist
+COPY docker/entrypoint.sh docker/merge-runtime-config.js ./
+COPY docker/config.example.json docker/config.full-example.json ./
+
+RUN chmod +x /app/entrypoint.sh
EXPOSE 8080
-CMD ["serve", "-s", "dist", "-l", "8080"]
+ENTRYPOINT ["/app/entrypoint.sh"]
diff --git a/docker/README.md b/docker/README.md
index 6c65246c1..c9aa4a65a 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -2,35 +2,89 @@
Two Dockerfiles are provided:
-- **Dockerfile** — production multi-stage build. Compiles the demo-app to static files and serves with `serve`.
+- **Dockerfile** — production multi-stage build. Compiles the demo-app to static files and serves with `serve`. Tokens and other deploy-specific settings are injected at **runtime** via `/config.json` and/or `KEPLER_*` env vars (not baked into the image).
- **Dockerfile.dev** — development build with esbuild watch mode inside the container.
## Prerequisites
1. [Docker](https://docs.docker.com/get-docker/) installed and running
-2. Create a `.env` file at the repository root (copy from `.env.template`):
+2. For local prod Compose with env overrides, create a `.env` file at the repository root (copy from `.env.template`):
```bash
cp .env.template .env
```
-Fill in at least `MapboxAccessToken` for the map to render.
+Fill in at least `MapboxAccessToken` if you want Mapbox basemaps. MapLibre/Carto defaults work without a token.
+
+## Runtime configuration
+
+The production image reads `/config.json` from the static root (`/app/dist/config.json`). Copy the minimal starter and fill in only what you need (empty credential strings are ignored):
+
+```bash
+cp docker/config.example.json docker/config.json
+```
+
+`docker/config.full-example.json` lists every supported key. Use it as a reference — do not mount it as-is (`mapUrl` boots a sample map, and `mapStyle.mapStyles` replaces the built-in basemap list).
+
+Mount it when running (uncomment the `volumes` block in `docker-compose.yml` after creating the file). Pick **one** of these patterns — do not combine a read-only mount with `KEPLER_*` overrides (the entrypoint must write the merged file):
+
+```yaml
+# A) Config file only (read-only is fine)
+volumes:
+ - ./config.json:/app/dist/config.json:ro
+
+# B) Config file + KEPLER_* env overrides (read-write mount required)
+volumes:
+ - ./config.json:/app/dist/config.json
+environment:
+ KEPLER_MAPBOX_ACCESS_TOKEN: ${MapboxAccessToken}
+
+# C) Env only — no volume; entrypoint writes /app/dist/config.json inside the container
+environment:
+ KEPLER_MAPBOX_ACCESS_TOKEN: ${MapboxAccessToken}
+ KEPLER_PAGE_TITLE: My Kepler
+```
+
+Supported `KEPLER_*` env vars (used in patterns B and C):
+
+| Env var | Config path |
+| --- | --- |
+| `KEPLER_MAPBOX_ACCESS_TOKEN` | `credentials.MapboxAccessToken` |
+| `KEPLER_MAPBOX_EXPORT_TOKEN` | `credentials.MapboxExportToken` |
+| `KEPLER_DROPBOX_CLIENT_ID` | `credentials.DropboxClientId` |
+| `KEPLER_CARTO_CLIENT_ID` | `credentials.CartoClientId` |
+| `KEPLER_FOURSQUARE_CLIENT_ID` | `credentials.FoursquareClientId` |
+| `KEPLER_FOURSQUARE_DOMAIN` | `credentials.FoursquareDomain` |
+| `KEPLER_FOURSQUARE_API_URL` | `credentials.FoursquareAPIURL` |
+| `KEPLER_FOURSQUARE_USER_MAPS_URL` | `credentials.FoursquareUserMapsURL` |
+| `KEPLER_GOOGLE_DRIVE_CLIENT_ID` | `credentials.GoogleDriveClientId` |
+| `KEPLER_MAP_CONFIG_URL` | `mapConfigUrl` |
+| `KEPLER_MAP_URL` | `mapUrl` |
+| `KEPLER_PAGE_TITLE` | `pageTitle` |
+
+See `docker/config.full-example.json` for every key supported today (credentials, `pageTitle`, `mapConfigUrl`, `mapUrl`, reducer `mapStyle`, KeplerGl `mapStyles` / `mapStylesReplaceDefault`, and serializable `applicationConfig` fields).
+
+Not JSON-configurable (need a source build): `plugins`, `table`, `database`, `baseMapLibraryConfig` (functions). Map style `layerGroups[].filter` callbacks also cannot be expressed in JSON.
## Running with Docker Compose
From the repository root:
```bash
-# Development mode (esbuild watch inside the container)
-docker compose -f docker/docker-compose.yml up kepler-dev
+# Optional runtime config — then uncomment `volumes` in docker-compose.yml
+cp docker/config.example.json docker/config.json
+
+# Development mode (esbuild watch inside the container; still uses build-time .env)
+docker compose -f docker/docker-compose.yml --env-file .env up kepler-dev
-# Production mode (static build served by serve)
-docker compose -f docker/docker-compose.yml up kepler-prod
+# Production mode (static build + runtime config / KEPLER_* from .env)
+# Without a mounted config.json, credential and KEPLER_MAP_* / KEPLER_PAGE_TITLE env still apply.
+docker compose -f docker/docker-compose.yml --env-file .env up kepler-prod
```
Then open http://localhost:8080.
-Once the image exists, omit `--build` so Compose reuses it and starts in seconds, not minutes. Pass `--build` only after source, Dockerfile, or `.env` changes. If Compose still starts a build, force the existing image with `--no-build`:
+Once the image exists, omit `--build` so Compose reuses it and starts in seconds, not minutes. Pass `--build` only after source or Dockerfile changes. If Compose still starts a build, force the existing image with `--no-build`:
```bash
docker compose -f docker/docker-compose.yml up --no-build kepler-prod
@@ -55,17 +109,49 @@ docker run -p 8080:8080 --env-file .env -e NODE_ENV=local kepler-dev
### Production
-Make sure `.env` exists at the root — env vars are baked in at build time:
+Build once, then choose a single runtime pattern.
+
+Creating a root `.env` does **not** export variables into your shell. For `docker run`, either pass values explicitly, use `--env-file` with `KEPLER_*` keys, or load `.env` into the shell first (`set -a && source .env && set +a`) so `$MapboxAccessToken` expands.
```bash
docker build -f docker/Dockerfile -t kepler-prod .
-docker run -p 8080:8080 kepler-prod
+
+# A) Config file only
+docker run -p 8080:8080 \
+ -v "$PWD/docker/config.json:/app/dist/config.json:ro" \
+ kepler-prod
+
+# B) Config file + KEPLER_* overrides (RW mount)
+# Option: explicit value
+docker run -p 8080:8080 \
+ -e KEPLER_MAPBOX_ACCESS_TOKEN='pk.your-token' \
+ -v "$PWD/docker/config.json:/app/dist/config.json" \
+ kepler-prod
+# Option: load root .env into the shell, then expand MapboxAccessToken
+# set -a && source .env && set +a
+# docker run ... -e KEPLER_MAPBOX_ACCESS_TOKEN="$MapboxAccessToken" ...
+
+# C) Env only — prefer --env-file with KEPLER_* keys (see table above)
+docker run -p 8080:8080 --env-file .env.kepler \
+ kepler-prod
+# Example .env.kepler:
+# KEPLER_MAPBOX_ACCESS_TOKEN=pk.your-token
+# KEPLER_PAGE_TITLE=kepler.gl demo
+```
+
+No-build deploy once a registry image exists (future) — env-only example:
+
+```bash
+docker run -p 8080:8080 \
+ -e KEPLER_MAPBOX_ACCESS_TOKEN='pk.your-token' \
+ ghcr.io/keplergl/kepler.gl:<tag>
```
## Notes
- The build context must be the repository root (both Dockerfiles reference `src/`, `scripts/`, etc.).
-- The `.dockerignore` at the root excludes nested `node_modules/`, other examples, `.git/`, `website/`, `bindings/`, `test/`, and `docs/` to keep the build context small. Yarn installs use a BuildKit cache mount so lockfile rebuilds reuse downloaded packages. Docker Desktop and Compose v2 enable BuildKit by default; if `docker build` fails on `--mount`, run it with `DOCKER_BUILDKIT=1`.
+- The `.dockerignore` at the root excludes nested `node_modules/`, other examples, `.git`, `website/`, `bindings/`, `test/`, `docs/`, and `.env*` so secrets are not copied into the build. Yarn installs use a BuildKit cache mount so lockfile rebuilds reuse downloaded packages. Docker Desktop and Compose v2 enable BuildKit by default; if `docker build` fails on `--mount`, run it with `DOCKER_BUILDKIT=1`.
- All postinstall scripts are disabled during `yarn install` to avoid building the `gl` native package (requires GPU headers, only used for tests). The `esbuild` platform binary is then installed selectively since it's required for bundling.
-- Environment variables like `MapboxAccessToken` are read from the `.env` file copied into the build context. Rebuild the image to change them.
+- Production images are built **without** baking Mapbox/cloud tokens. Change tokens by remounting `config.json` or updating `KEPLER_*` env and restarting — no rebuild.
+- The dev image still reads `.env` at container start for esbuild `define` (watch/rebuild path). Prefer the prod image for deployable runtime injection.
- The dev image provides a no-op `xdg-open` to prevent the server from crashing when it tries to open a browser.
diff --git a/docker/config.example.json b/docker/config.example.json
new file mode 100644
index 000000000..8cd9465ed
--- /dev/null
+++ b/docker/config.example.json
@@ -0,0 +1,9 @@
+{
+ "credentials": {
+ "MapboxAccessToken": ""
+ },
+ "pageTitle": "kepler.gl demo",
+ "applicationConfig": {
+ "enableThemeToggle": true
+ }
+}
diff --git a/docker/config.full-example.json b/docker/config.full-example.json
new file mode 100644
index 000000000..d7a00c823
--- /dev/null
+++ b/docker/config.full-example.json
@@ -0,0 +1,141 @@
+{
+ "credentials": {
+ "MapboxAccessToken": "pk.your-mapbox-token",
+ "MapboxExportToken": "pk.your-mapbox-export-token",
+ "DropboxClientId": "your-dropbox-client-id",
+ "CartoClientId": "your-carto-client-id",
+ "FoursquareClientId": "your-foursquare-client-id",
+ "FoursquareDomain": "your-tenant.auth0.com",
+ "FoursquareAPIURL": "https://api.foursquare.com",
+ "FoursquareUserMapsURL": "https://foursquare.com/user/maps",
+ "GoogleDriveClientId": "your-id.apps.googleusercontent.com"
+ },
+
+ "pageTitle": "kepler.gl demo",
+
+ "mapConfigUrl": "https://raw.githubusercontent.com/keplergl/kepler.gl-data/master/samples.json",
+
+ "mapUrl": "https://raw.githubusercontent.com/keplergl/kepler.gl-data/master/nyctrips/config.json",
+
+ "mapStyle": {
+ "styleType": "voyager",
+ "mapStyles": {
+ "voyager": {
+ "id": "voyager",
+ "label": "Voyager",
+ "url": "https://api.maptiler.com/maps/voyager/style.json?key=YOUR_KEY",
+ "icon": "https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=YOUR_KEY"
+ },
+ "outdoor": {
+ "id": "outdoor",
+ "label": "Outdoor",
+ "url": "https://api.maptiler.com/maps/outdoor/style.json?key=YOUR_KEY",
+ "icon": "https://openmaptiles.org/img/styles/terrain.jpg"
+ }
+ }
+ },
+
+ "mapStyles": [
+ {
+ "id": "voyager",
+ "label": "Voyager",
+ "url": "https://api.maptiler.com/maps/voyager/style.json?key=YOUR_KEY",
+ "icon": "https://api.maptiler.com/maps/voyager/256/0/0/0.png?key=YOUR_KEY"
+ }
+ ],
+ "mapStylesReplaceDefault": false,
+
+ "applicationConfig": {
+ "defaultHtmlName": "kepler.gl.html",
+ "defaultImageName": "kepler.gl.png",
+ "defaultJsonName": "kepler.gl.json",
+ "defaultDataName": "kepler.gl",
+ "defaultExportJsonSettings": {
+ "hasData": true
+ },
+
+ "cdnUrl": "https://studio-public-data.foursquare.com/statics/keplergl",
+
+ "useArrowProgressiveLoading": true,
+ "showReleaseBanner": true,
+ "useOnFilteredItemsChange": false,
+ "escapeXhtmlForWebpack": true,
+ "maxPitch": 60,
+ "maxArrowBatches": 1,
+ "reduxLogLevel": 1,
+
+ "enableRasterTileLayer": true,
+ "rasterServerUseLatestTitiler": true,
+ "rasterServerShowServerInput": true,
+ "rasterServerUrls": [
+ "https://your-titiler.example.com"
+ ],
+ "rasterServerSupportsElevation": true,
+ "rasterServerMaxRetries": 1,
+ "rasterServerRetryDelay": 10000,
+ "rasterServerServerErrorsToRetry": [503],
+ "rasterServerMaxPerServerRequests": 0,
+
+ "enableWMSLayer": true,
+ "enableFlowLayer": true,
+ "enableBitmapLayer": true,
+ "enableA5Layer": true,
+ "enableGeohashLayer": true,
+
+ "showInlineTilesetExamples": true,
+
+ "enableAnnotations": true,
+ "enableDrawOnMapSketches": true,
+ "enableMapNavigationControl": true,
+ "enableMapScale": true,
+ "enableSwipeMode": true,
+ "enableGlobeView": true,
+ "enableLayerGroups": true,
+ "enableThemeToggle": true,
+ "enableColumnStats": true,
+ "enableRemoteFileFormatSelector": false,
+
+ "acceptedFileFormats": [
+ "csv",
+ "tsv",
+ "dsv",
+ "json",
+ "geojson",
+ "ndjson",
+ "jsonl",
+ "geojsonl",
+ "ndgeojson",
+ "ldgeojson",
+ "kml",
+ "gpx",
+ "tcx",
+ "arrow",
+ "feather",
+ "parquet"
+ ],
+
+ "customIconUrl": "https://raw.githubusercontent.com/keplergl/kepler.gl-data/refs/heads/master/layers/icon/custom-icons.json",
+ "customIcons": [
+ {
+ "id": "custom-star",
+ "mesh": {
+ "cells": [
+ [5, 1, 0],
+ [5, 2, 1],
+ [5, 3, 2],
+ [5, 4, 3],
+ [5, 0, 4]
+ ],
+ "positions": [
+ [0, 1, 0],
+ [0.95, 0.31, 0],
+ [0.59, -0.81, 0],
+ [-0.59, -0.81, 0],
+ [-0.95, 0.31, 0],
+ [0, 0, 0]
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 02b60cc85..d1baed1c8 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -16,3 +16,23 @@ services:
dockerfile: docker/Dockerfile
ports:
- "8080:8080"
+ # Optional: mount a runtime config after `cp docker/config.example.json docker/config.json`
+ # (minimal starter). See config.full-example.json for every key.
+ # Do not enable this line until the file exists — Docker will otherwise create a directory
+ # named config.json and the container will fail.
+ # volumes:
+ # - ./config.json:/app/dist/config.json
+ environment:
+ # Optional overrides (merged into /app/dist/config.json by the entrypoint)
+ KEPLER_MAPBOX_ACCESS_TOKEN: ${MapboxAccessToken:-}
+ KEPLER_MAPBOX_EXPORT_TOKEN: ${MapboxExportToken:-}
+ KEPLER_DROPBOX_CLIENT_ID: ${DropboxClientId:-}
+ KEPLER_CARTO_CLIENT_ID: ${CartoClientId:-}
+ KEPLER_FOURSQUARE_CLIENT_ID: ${FoursquareClientId:-}
+ KEPLER_FOURSQUARE_DOMAIN: ${FoursquareDomain:-}
+ KEPLER_FOURSQUARE_API_URL: ${FoursquareAPIURL:-}
+ KEPLER_FOURSQUARE_USER_MAPS_URL: ${FoursquareUserMapsURL:-}
+ KEPLER_GOOGLE_DRIVE_CLIENT_ID: ${GoogleDriveClientId:-}
+ KEPLER_MAP_CONFIG_URL: ${KEPLER_MAP_CONFIG_URL:-}
+ KEPLER_MAP_URL: ${KEPLER_MAP_URL:-}
+ KEPLER_PAGE_TITLE: ${KEPLER_PAGE_TITLE:-}
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100755
index 000000000..cb12ffbf0
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+set -eu
+
+CONFIG_PATH="${KEPLER_CONFIG_PATH:-/app/dist/config.json}"
+export KEPLER_CONFIG_PATH="$CONFIG_PATH"
+
+node /app/merge-runtime-config.js
+
+exec serve -s dist -l 8080
diff --git a/docker/merge-runtime-config.js b/docker/merge-runtime-config.js
new file mode 100644
index 000000000..7969f74da
--- /dev/null
+++ b/docker/merge-runtime-config.js
@@ -0,0 +1,97 @@
+#!/usr/bin/env node
+/**
+ * Merge KEPLER_* environment variables into dist/config.json before serve.
+ * Existing config.json (e.g. volume mount) wins for keys not set via env;
+ * env overrides matching keys.
+ *
+ * Supported env vars:
+ * KEPLER_MAPBOX_ACCESS_TOKEN
+ * KEPLER_MAPBOX_EXPORT_TOKEN
+ * KEPLER_DROPBOX_CLIENT_ID
+ * KEPLER_CARTO_CLIENT_ID
+ * KEPLER_FOURSQUARE_CLIENT_ID
+ * KEPLER_FOURSQUARE_DOMAIN
+ * KEPLER_FOURSQUARE_API_URL
+ * KEPLER_FOURSQUARE_USER_MAPS_URL
+ * KEPLER_GOOGLE_DRIVE_CLIENT_ID
+ * KEPLER_MAP_CONFIG_URL
+ * KEPLER_MAP_URL
+ * KEPLER_PAGE_TITLE
+ */
+const fs = require('fs');
+const path = require('path');
+
+const CONFIG_PATH = process.env.KEPLER_CONFIG_PATH || path.join(__dirname, 'dist', 'config.json');
+
+const ENV_CREDENTIALS = {
+ KEPLER_MAPBOX_ACCESS_TOKEN: 'MapboxAccessToken',
+ KEPLER_MAPBOX_EXPORT_TOKEN: 'MapboxExportToken',
+ KEPLER_DROPBOX_CLIENT_ID: 'DropboxClientId',
+ KEPLER_CARTO_CLIENT_ID: 'CartoClientId',
+ KEPLER_FOURSQUARE_CLIENT_ID: 'FoursquareClientId',
+ KEPLER_FOURSQUARE_DOMAIN: 'FoursquareDomain',
+ KEPLER_FOURSQUARE_API_URL: 'FoursquareAPIURL',
+ KEPLER_FOURSQUARE_USER_MAPS_URL: 'FoursquareUserMapsURL',
+ KEPLER_GOOGLE_DRIVE_CLIENT_ID: 'GoogleDriveClientId'
+};
+
+const ENV_TOP_LEVEL = {
+ KEPLER_MAP_CONFIG_URL: 'mapConfigUrl',
+ KEPLER_MAP_URL: 'mapUrl',
+ KEPLER_PAGE_TITLE: 'pageTitle'
+};
+
+function readExistingConfig() {
+ try {
+ if (!fs.existsSync(CONFIG_PATH)) {
+ return {};
+ }
+ const raw = fs.readFileSync(CONFIG_PATH, 'utf8');
+ const parsed = JSON.parse(raw);
+ return parsed && typeof parsed === 'object' ? parsed : {};
+ } catch (err) {
+ console.warn(`[kepler-entrypoint] Could not read ${CONFIG_PATH}: ${err.message}`);
+ return {};
+ }
+}
+
+function mergeRuntimeConfig() {
+ const config = readExistingConfig();
+ config.credentials =
+ config.credentials && typeof config.credentials === 'object' ? config.credentials : {};
+
+ let changed = false;
+
+ for (const [envKey, credKey] of Object.entries(ENV_CREDENTIALS)) {
+ const value = process.env[envKey];
+ if (typeof value === 'string' && value.length > 0) {
+ config.credentials[credKey] = value;
+ changed = true;
+ }
+ }
+
+ for (const [envKey, configKey] of Object.entries(ENV_TOP_LEVEL)) {
+ const value = process.env[envKey];
+ if (typeof value === 'string' && value.length > 0) {
+ config[configKey] = value;
+ changed = true;
+ }
+ }
+
+ // Always write when env set, or when no file exists yet (so volume-less deploys get {}).
+ if (changed || !fs.existsSync(CONFIG_PATH)) {
+ try {
+ fs.mkdirSync(path.dirname(CONFIG_PATH), {recursive: true});
+ fs.writeFileSync(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
+ console.log(`[kepler-entrypoint] Wrote runtime config to ${CONFIG_PATH}`);
+ } catch (err) {
+ // Read-only volume mounts are expected; keep serving the mounted file.
+ console.warn(
+ `[kepler-entrypoint] Could not write ${CONFIG_PATH} (${err.message}). ` +
+ 'Using existing config as-is; KEPLER_* env overrides were not applied.'
+ );
+ }
+ }
+}
+
+mergeRuntimeConfig();
diff --git a/examples/demo-app/README.md b/examples/demo-app/README.md
index de0219ab7..9f7dca0d5 100644
--- a/examples/demo-app/README.md
+++ b/examples/demo-app/README.md
@@ -66,4 +66,8 @@ For Google Drive, create an OAuth 2.0 **Web application** client in [Google Clou
yarn start:local
```
+#### Optional: runtime `/config.json`
+
+After a production build (`yarn build`), you can override tokens and demo-app settings without rebuilding by placing a `config.json` next to `dist/index.html` (i.e. `examples/demo-app/dist/config.json`). Copy `docker/config.example.json` as a starter; see `docker/config.full-example.json` and `docker/README.md` for the full schema, Compose mounts, and `KEPLER_*` env overrides.
+
[yarn-install]: https://yarnpkg.com/getting-started/install
diff --git a/examples/demo-app/src/actions.js b/examples/demo-app/src/actions.js
index 62da09e70..05ccc7de5 100644
--- a/examples/demo-app/src/actions.js
+++ b/examples/demo-app/src/actions.js
@@ -12,7 +12,7 @@ import {ParquetWasmLoader} from '@loaders.gl/parquet';
import {
LOADING_SAMPLE_ERROR_MESSAGE,
LOADING_SAMPLE_LIST_ERROR_MESSAGE,
- MAP_CONFIG_URL
+ getMapConfigUrl
} from './constants/default-settings';
// CONSTANTS
@@ -287,7 +287,8 @@ function loadRemoteData(url) {
*/
export function loadSampleConfigurations(sampleMapId = null) {
return dispatch => {
- fetch(MAP_CONFIG_URL)
+ const mapConfigUrl = getMapConfigUrl();
+ fetch(mapConfigUrl)
.then(response => {
if (!response.ok) {
return response.text().then(text => {
@@ -309,7 +310,7 @@ export function loadSampleConfigurations(sampleMapId = null) {
dispatch(
loadRemoteResourceError(
{message: `${error} - ${LOADING_SAMPLE_LIST_ERROR_MESSAGE}`},
- MAP_CONFIG_URL
+ mapConfigUrl
)
);
});
diff --git a/examples/demo-app/src/app.tsx b/examples/demo-app/src/app.tsx
index a5580f59a..0ec976886 100644
--- a/examples/demo-app/src/app.tsx
+++ b/examples/demo-app/src/app.tsx
@@ -23,6 +23,7 @@ import {replaceMapControl} from './factories/map-control';
import {replacePanelHeader} from './factories/panel-header';
import {CLOUD_PROVIDERS_CONFIGURATION, DEFAULT_FEATURE_FLAGS} from './constants/default-settings';
import {messages} from './constants/localization';
+import {getRuntimeConfig} from './utils/runtime-config';
import {
loadRemoteMap,
@@ -174,6 +175,7 @@ const App = props => {
const mapContainerRef = useRef<HTMLDivElement>(null);
const [mapDimensions, setMapDimensions] = useState({width: 0, height: 0});
+ const runtime = getRuntimeConfig();
useEffect(() => {
if (!mapContainerRef.current) return;
@@ -221,10 +223,13 @@ const App = props => {
dispatch(loadSampleConfigurations(id));
}
- // Load map using a custom
+ // Load map using a custom URL. Prefer ?mapUrl=; otherwise use runtime config
+ // only when no /demo/:id sample is being loaded (avoids racing two map loads).
if (query.mapUrl) {
// TODO?: validate map url
dispatch(loadRemoteMap({dataUrl: query.mapUrl}));
+ } else if (!id && runtime.mapUrl) {
+ dispatch(loadRemoteMap({dataUrl: runtime.mapUrl}));
}
if (duckDbPluginEnabled && query.sql) {
@@ -914,6 +919,12 @@ const App = props => {
onLoadCloudMapSuccess={onLoadCloudMapSuccess}
featureFlags={DEFAULT_FEATURE_FLAGS}
onViewStateChange={onViewStateChange}
+ {...(Array.isArray(runtime.mapStyles)
+ ? {
+ mapStyles: runtime.mapStyles,
+ mapStylesReplaceDefault: Boolean(runtime.mapStylesReplaceDefault)
+ }
+ : {})}
/>
</div>
</Panel>
diff --git a/examples/demo-app/src/cloud-providers/index.js b/examples/demo-app/src/cloud-providers/index.js
index cafa17b86..977d4e19b 100644
--- a/examples/demo-app/src/cloud-providers/index.js
+++ b/examples/demo-app/src/cloud-providers/index.js
@@ -23,6 +23,7 @@ const GOOGLE_DRIVE_APP_NAME = 'Kepler.gl';
export const DEFAULT_CLOUD_PROVIDER = 'dropbox';
+// Instantiated after main.js applies /config.json credentials (dynamic import).
export const CLOUD_PROVIDERS = [
new FoursquareProvider({
clientId: FOURSQUARE_CLIENT_ID,
diff --git a/examples/demo-app/src/constants/default-settings.js b/examples/demo-app/src/constants/default-settings.js
index 32ce39195..4624edea2 100644
--- a/examples/demo-app/src/constants/default-settings.js
+++ b/examples/demo-app/src/constants/default-settings.js
@@ -8,10 +8,27 @@ import keyMirror from 'keymirror';
export const ASSETS_URL = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/';
export const DATA_URL = 'https://raw.githubusercontent.com/keplergl/kepler.gl-data/master/';
export const MAP_URI = 'demo/map?mapUrl=';
-/*
- * If you want to add more samples, feel free to edit the json file on github kepler.gl data repo
+
+/** Override via `/config.json` `mapConfigUrl` (see runtime-config.js). */
+let mapConfigUrlOverride = null;
+
+/**
+ * Sample gallery catalogue URL. Cache-busted by default; runtime config can replace it.
+ * @returns {string}
+ */
+export function getMapConfigUrl() {
+ if (mapConfigUrlOverride) {
+ return mapConfigUrlOverride;
+ }
+ return `${DATA_URL}samples.json?nocache=${new Date().getTime()}`;
+}
+
+/**
+ * @param {string} url
*/
-export const MAP_CONFIG_URL = `${DATA_URL}samples.json?nocache=${new Date().getTime()}`;
+export function setMapConfigUrl(url) {
+ mapConfigUrlOverride = url;
+}
/**
* I know this is already defined in Kepler core but it should be defined here
diff --git a/examples/demo-app/src/main.js b/examples/demo-app/src/main.js
index cf3c909ad..6b68d88d0 100644
--- a/examples/demo-app/src/main.js
+++ b/examples/demo-app/src/main.js
@@ -5,24 +5,39 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import {Provider} from 'react-redux';
import {BrowserRouter, Routes, Route} from 'react-router-dom';
-import store from './store';
-import App from './app';
-const Root = () => (
- <Provider store={store}>
- <BrowserRouter>
- <Routes>
- <Route path="/" element={<App />} />
- <Route path="/auth" element={<App />} />
- <Route path="/demo" element={<App />} />
- <Route path="/demo/map" element={<App />} />
- <Route path="/demo/map/:provider" element={<App />} />
- <Route path="/demo/:id" element={<App />} />
- </Routes>
- </BrowserRouter>
- </Provider>
-);
+import {loadAndApplyRuntimeConfig} from './utils/runtime-config';
-const root = ReactDOM.createRoot(document.getElementById('root'));
+async function bootstrap() {
+ // Credentials / applicationConfig / mapStyle must be applied before the store
+ // (and cloud providers) are imported — those modules read config at load time.
+ await loadAndApplyRuntimeConfig();
-root.render(<Root />);
+ const [{default: store}, {default: App}] = await Promise.all([
+ import('./store'),
+ import('./app')
+ ]);
+
+ const Root = () => (
+ <Provider store={store}>
+ <BrowserRouter>
+ <Routes>
+ <Route path="/" element={<App />} />
+ <Route path="/auth" element={<App />} />
+ <Route path="/demo" element={<App />} />
+ <Route path="/demo/map" element={<App />} />
+ <Route path="/demo/map/:provider" element={<App />} />
+ <Route path="/demo/:id" element={<App />} />
+ </Routes>
+ </BrowserRouter>
+ </Provider>
+ );
+
+ const root = ReactDOM.createRoot(document.getElementById('root'));
+ root.render(<Root />);
+}
+
+bootstrap().catch(err => {
+ // eslint-disable-next-line no-console
+ console.error('Failed to start kepler.gl demo app', err);
+});
diff --git a/examples/demo-app/src/reducers/index.js b/examples/demo-app/src/reducers/index.js
index 375c3abd8..c0a02137b 100644
--- a/examples/demo-app/src/reducers/index.js
+++ b/examples/demo-app/src/reducers/index.js
@@ -12,10 +12,11 @@ import KeplerGlSchema from '@kepler.gl/schemas';
import {KeplerTable} from '@kepler.gl/table';
import {getApplicationConfig} from '@kepler.gl/utils';
-// import {getApplicationConfig, initApplicationConfig} from '@kepler.gl/utils';
-// import keplerGlDuckdbPlugin, {KeplerGlDuckDbTable, DuckDBWasmAdapter} from '@kepler.gl/duckdb';
-
-import {initApplicationConfig} from '@kepler.gl/utils';
+// DuckDB / applicationConfig defaults: see utils/runtime-config.js (applied on
+// import, and overlaid from /config.json in demo-app main.js). To enable DuckDB
+// locally, call initApplicationConfig from runtime-config or pass
+// applicationConfig via /config.json — plugins still need a source build that
+// bundles them.
import {
INIT,
@@ -29,62 +30,16 @@ import {
import {CLOUD_PROVIDERS_CONFIGURATION} from '../constants/default-settings';
import {generateHashId} from '../utils/strings';
-
-// initialize kepler demo-app with DuckDB plugin
-/*
-initApplicationConfig({
- // Custom UI for DuckDB
- plugins: [keplerGlDuckdbPlugin],
- // async data ingestion to DuckDb
- table: KeplerGlDuckDbTable,
- // setup database for DuckDB plugin
- database: new DuckDBWasmAdapter({
- config: {
- query: {
- castBigIntToDouble: true
- }
- }
- }),
- // progressive loading is sync, doesn't wait properly for a dataset to be created in DuckDB
- useArrowProgressiveLoading: false
-});
-*/
-
-// Example: Register custom icons for the icon layer.
-// These will be merged with the default icons fetched from CDN.
-// Data values in the "icon" column matching these IDs will render the custom shapes.
-// NOTE: Cell winding must be counter-clockwise (CCW) to match the CDN icon convention.
-initApplicationConfig({
- enableA5Layer: true,
- enableGeohashLayer: true,
- customIcons: [
- {
- id: 'custom-star',
- mesh: {
- cells: [
- [5, 1, 0],
- [5, 2, 1],
- [5, 3, 2],
- [5, 4, 3],
- [5, 0, 4]
- ],
- positions: [
- [0, 1, 0],
- [0.95, 0.31, 0],
- [0.59, -0.81, 0],
- [-0.59, -0.81, 0],
- [-0.95, 0.31, 0],
- [0, 0, 0]
- ]
- }
- }
- ],
- customIconUrl:
- 'https://raw.githubusercontent.com/keplergl/kepler.gl-data/refs/heads/master/layers/icon/custom-icons.json'
-});
+import {getRuntimeConfig} from '../utils/runtime-config';
const {DEFAULT_MAP_CONTROLS} = uiStateUpdaters;
+const runtimeConfig = getRuntimeConfig();
+const runtimeMapStyle =
+ runtimeConfig.mapStyle && (runtimeConfig.mapStyle.mapStyles || runtimeConfig.mapStyle.styleType)
+ ? runtimeConfig.mapStyle
+ : null;
+
// INITIAL_APP_STATE
const initialAppState = {
appName: 'example',
@@ -152,7 +107,16 @@ const demoReducer = combineReducers({
visState: {
loaders: [], // Add additional loaders.gl loaders here
loadOptions: {} // Add additional loaders.gl loader options here
- }
+ },
+ // Optional custom base maps from /config.json (see docs/custom-map-styles.md option 2)
+ ...(runtimeMapStyle
+ ? {
+ mapStyle: {
+ ...(runtimeMapStyle.mapStyles ? {mapStyles: runtimeMapStyle.mapStyles} : {}),
+ ...(runtimeMapStyle.styleType ? {styleType: runtimeMapStyle.styleType} : {})
+ }
+ }
+ : {})
}),
app: appReducer,
aiAssistant: aiAssistantReducer
diff --git a/examples/demo-app/src/utils/runtime-config.js b/examples/demo-app/src/utils/runtime-config.js
new file mode 100644
index 000000000..871bf1adf
--- /dev/null
+++ b/examples/demo-app/src/utils/runtime-config.js
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: MIT
+// Copyright contributors to the kepler.gl project
+
+import {initApplicationConfig} from '@kepler.gl/utils';
+
+import {CLOUD_PROVIDERS_CONFIGURATION, setMapConfigUrl} from '../constants/default-settings';
+
+/**
+ * Demo-app-only runtime config loaded from `/config.json` (volume mount or
+ * Docker entrypoint). Kept separate from library {@link KeplerApplicationConfig}
+ * so tokens, sample gallery URL, boot map, and branding stay out of the core type.
+ *
+ * @typedef {object} DemoAppRuntimeConfig
+ * @property {object} [credentials]
+ * @property {string} [credentials.MapboxAccessToken]
+ * @property {string} [credentials.MapboxExportToken]
+ * @property {string} [credentials.DropboxClientId]
+ * @property {string} [credentials.CartoClientId]
+ * @property {string} [credentials.FoursquareClientId]
+ * @property {string} [credentials.FoursquareDomain]
+ * @property {string} [credentials.FoursquareAPIURL]
+ * @property {string} [credentials.FoursquareUserMapsURL]
+ * @property {string} [credentials.GoogleDriveClientId]
+ * @property {import('@kepler.gl/utils').KeplerApplicationConfig} [applicationConfig]
+ * @property {{mapStyles?: object, styleType?: string}} [mapStyle]
+ * @property {Array<object>} [mapStyles] KeplerGl prop form (array of styles)
+ * @property {boolean} [mapStylesReplaceDefault]
+ * @property {string} [mapConfigUrl] Sample gallery `samples.json` URL
+ * @property {string} [mapUrl] Map JSON to load on boot when `?mapUrl=` is absent
+ * @property {string} [pageTitle]
+ */
+
+/** @type {DemoAppRuntimeConfig} */
+let runtimeConfig = {};
+
+const CREDENTIAL_TO_CLOUD_KEY = {
+ MapboxAccessToken: 'MAPBOX_TOKEN',
+ MapboxExportToken: 'EXPORT_MAPBOX_TOKEN',
+ DropboxClientId: 'DROPBOX_CLIENT_ID',
+ CartoClientId: 'CARTO_CLIENT_ID',
+ FoursquareClientId: 'FOURSQUARE_CLIENT_ID',
+ FoursquareDomain: 'FOURSQUARE_DOMAIN',
+ FoursquareAPIURL: 'FOURSQUARE_API_URL',
+ FoursquareUserMapsURL: 'FOURSQUARE_USER_MAPS_URL',
+ GoogleDriveClientId: 'GOOGLE_DRIVE_CLIENT_ID'
+};
+
+/**
+ * Built-in demo-app applicationConfig defaults (previously set in reducers/index.js).
+ * Applied on first import so kepler.gl.com (website store/app) keeps the same
+ * icons/flags, and again from {@link loadAndApplyRuntimeConfig} before any
+ * `/config.json` overlay so Docker/source builds can still override them.
+ *
+ * To enable DuckDB in a source build, also register the plugin here (or via a custom
+ * bootstrap), e.g.:
+ * initApplicationConfig({
+ * plugins: [keplerGlDuckdbPlugin],
+ * table: KeplerGlDuckDbTable,
+ * database: new DuckDBWasmAdapter(...),
+ * useArrowProgressiveLoading: false
+ * });
+ * Plugins cannot be loaded from JSON alone — they must be bundled.
+ */
+export function applyDemoApplicationDefaults() {
+ initApplicationConfig({
+ enableA5Layer: true,
+ enableGeohashLayer: true,
+ customIcons: [
+ {
+ id: 'custom-star',
+ mesh: {
+ cells: [
+ [5, 1, 0],
+ [5, 2, 1],
+ [5, 3, 2],
+ [5, 4, 3],
+ [5, 0, 4]
+ ],
+ positions: [
+ [0, 1, 0],
+ [0.95, 0.31, 0],
+ [0.59, -0.81, 0],
+ [-0.59, -0.81, 0],
+ [-0.95, 0.31, 0],
+ [0, 0, 0]
+ ]
+ }
+ }
+ ],
+ customIconUrl:
+ 'https://raw.githubusercontent.com/keplergl/kepler.gl-data/refs/heads/master/layers/icon/custom-icons.json'
+ });
+}
+
+// Website imports demo-app reducers/app without going through demo-app main.js.
+applyDemoApplicationDefaults();
+
+/**
+ * @param {DemoAppRuntimeConfig['credentials']} credentials
+ */
+export function applyCredentials(credentials = {}) {
+ const safeCredentials =
+ credentials && typeof credentials === 'object' && !Array.isArray(credentials)
+ ? credentials
+ : {};
+
+ Object.entries(CREDENTIAL_TO_CLOUD_KEY).forEach(([fromKey, toKey]) => {
+ const value = safeCredentials[fromKey];
+ if (typeof value === 'string' && value.length > 0) {
+ CLOUD_PROVIDERS_CONFIGURATION[toKey] = value;
+ }
+ });
+}
+
+/**
+ * @param {DemoAppRuntimeConfig} config
+ */
+export function applyRuntimeConfig(config = {}) {
+ runtimeConfig = config;
+
+ applyCredentials(config.credentials);
+
+ if (config.applicationConfig && typeof config.applicationConfig === 'object') {
+ initApplicationConfig(config.applicationConfig);
+ }
+
+ if (typeof config.mapConfigUrl === 'string' && config.mapConfigUrl.length > 0) {
+ setMapConfigUrl(config.mapConfigUrl);
+ }
+
+ if (typeof config.pageTitle === 'string' && config.pageTitle.length > 0) {
+ document.title = config.pageTitle;
+ }
+}
+
+/** @returns {DemoAppRuntimeConfig} */
+export function getRuntimeConfig() {
+ return runtimeConfig;
+}
+
+/**
+ * Fetch `/config.json` when present. Missing or invalid files are a no-op so
+ * local source builds and static hosting without a mount keep working.
+ * @returns {Promise<DemoAppRuntimeConfig>}
+ */
+export async function loadRuntimeConfigJson() {
+ try {
+ const response = await fetch('/config.json', {cache: 'no-store'});
+ if (!response.ok) {
+ return {};
+ }
+ const json = await response.json();
+ return json && typeof json === 'object' ? json : {};
+ } catch {
+ return {};
+ }
+}
+
+/**
+ * Apply demo defaults, then overlay `/config.json` when available.
+ * Must run before dynamic import of the Redux store so reducer initial state
+ * and cloud providers see runtime credentials / mapStyle.
+ * @returns {Promise<DemoAppRuntimeConfig>}
+ */
+export async function loadAndApplyRuntimeConfig() {
+ applyDemoApplicationDefaults();
+ const remote = await loadRuntimeConfigJson();
+ applyRuntimeConfig(remote);
+ return remote;
+}
diff --git a/test/node/docker/index.js b/test/node/docker/index.js
new file mode 100644
index 000000000..70b932ef1
--- /dev/null
+++ b/test/node/docker/index.js
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: MIT
+// Copyright contributors to the kepler.gl project
+
+import './merge-runtime-config-test';
diff --git a/test/node/docker/merge-runtime-config-test.js b/test/node/docker/merge-runtime-config-test.js
new file mode 100644
index 000000000..616832aa1
--- /dev/null
+++ b/test/node/docker/merge-runtime-config-test.js
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: MIT
+// Copyright contributors to the kepler.gl project
+
+import fs from 'fs';
+import os from 'os';
+import path from 'path';
+import {spawnSync} from 'child_process';
+import test from 'tape';
+
+const MERGE_SCRIPT = path.resolve(__dirname, '../../../docker/merge-runtime-config.js');
+const EXAMPLE_CONFIG = path.resolve(__dirname, '../../../docker/config.example.json');
+const FULL_EXAMPLE_CONFIG = path.resolve(__dirname, '../../../docker/config.full-example.json');
+
+function runMerge(env, configPath) {
+ return spawnSync(process.execPath, [MERGE_SCRIPT], {
+ encoding: 'utf8',
+ env: {
+ ...process.env,
+ ...env,
+ KEPLER_CONFIG_PATH: configPath
+ }
+ });
+}
+
+function readConfig(configPath) {
+ return JSON.parse(fs.readFileSync(configPath, 'utf8'));
+}
+
+test('docker/config.example.json is a valid minimal starter', t => {
+ const example = JSON.parse(fs.readFileSync(EXAMPLE_CONFIG, 'utf8'));
+ t.ok(example.credentials && typeof example.credentials === 'object', 'has credentials');
+ t.notOk(example.mapUrl, 'minimal starter does not boot a map');
+ t.end();
+});
+
+test('docker/config.full-example.json lists supported keys', t => {
+ const example = JSON.parse(fs.readFileSync(FULL_EXAMPLE_CONFIG, 'utf8'));
+ t.ok(example.credentials && typeof example.credentials === 'object', 'has credentials');
+ t.ok('mapUrl' in example, 'has mapUrl');
+ t.ok(
+ example.applicationConfig && typeof example.applicationConfig === 'object',
+ 'has applicationConfig'
+ );
+ t.end();
+});
+
+test('merge-runtime-config writes env-only config when no file exists', t => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kepler-runtime-config-'));
+ const configPath = path.join(dir, 'config.json');
+
+ const result = runMerge(
+ {
+ KEPLER_MAPBOX_ACCESS_TOKEN: 'pk.ci-test',
+ KEPLER_PAGE_TITLE: 'ci-title',
+ KEPLER_MAP_URL: 'https://example.com/map.json'
+ },
+ configPath
+ );
+
+ t.equal(result.status, 0, result.stderr || 'exit 0');
+ t.ok(fs.existsSync(configPath), 'wrote config.json');
+
+ const config = readConfig(configPath);
+ t.equal(config.credentials.MapboxAccessToken, 'pk.ci-test');
+ t.equal(config.pageTitle, 'ci-title');
+ t.equal(config.mapUrl, 'https://example.com/map.json');
+ t.notOk(config.credentials.DropboxClientId, 'empty env does not set other credentials');
+
+ fs.rmSync(dir, {recursive: true, force: true});
+ t.end();
+});
+
+test('merge-runtime-config overlays KEPLER_* onto an existing config file', t => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kepler-runtime-config-'));
+ const configPath = path.join(dir, 'config.json');
+ fs.writeFileSync(
+ configPath,
+ `${JSON.stringify(
+ {
+ credentials: {MapboxAccessToken: 'pk.from-file', DropboxClientId: 'dropbox-from-file'},
+ pageTitle: 'from-file'
+ },
+ null,
+ 2
+ )}\n`
+ );
+
+ const result = runMerge(
+ {
+ KEPLER_MAPBOX_ACCESS_TOKEN: 'pk.from-env',
+ KEPLER_MAPBOX_EXPORT_TOKEN: ''
+ },
+ configPath
+ );
+
+ t.equal(result.status, 0, result.stderr || 'exit 0');
+ const config = readConfig(configPath);
+ t.equal(config.credentials.MapboxAccessToken, 'pk.from-env', 'env overrides matching keys');
+ t.equal(config.credentials.DropboxClientId, 'dropbox-from-file', 'file wins for unset env');
+ t.equal(config.pageTitle, 'from-file', 'unset top-level env leaves file value');
+
+ fs.rmSync(dir, {recursive: true, force: true});
+ t.end();
+});
+
+test('merge-runtime-config writes empty credentials when nothing is set', t => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kepler-runtime-config-'));
+ const configPath = path.join(dir, 'config.json');
+
+ const result = runMerge({}, configPath);
+ t.equal(result.status, 0, result.stderr || 'exit 0');
+ t.deepEqual(readConfig(configPath), {credentials: {}});
+
+ fs.rmSync(dir, {recursive: true, force: true});
+ t.end();
+});
diff --git a/test/node/index.js b/test/node/index.js
index f9817c128..07544a9a1 100644
--- a/test/node/index.js
+++ b/test/node/index.js
@@ -12,3 +12,6 @@ import './schemas';
// test processers
import './processors';
+
+// docker runtime config (entrypoint merge script)
+import './docker';