|
| 1 | +# Unify Docker Image by Removing SageMaker Variant |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Accepted |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +Graph Explorer ships two Docker images from the same Dockerfile: a main image and a |
| 10 | +SageMaker image built with `--build-arg NEPTUNE_NOTEBOOK=true`. The build argument |
| 11 | +bakes different environment variable defaults into the image (port 9250 instead of 80, |
| 12 | +cloudwatch logging, a different Vite `base` path for static assets). The SageMaker |
| 13 | +lifecycle script already passes all these values as runtime environment variables, |
| 14 | +making the build-time split unnecessary. |
| 15 | + |
| 16 | +Additionally, the client requires users to manually specify a "Public or Proxy |
| 17 | +Endpoint" URL even though the proxy server and UI are always served from the same |
| 18 | +origin. This creates confusion and an extra configuration step that can be derived |
| 19 | +automatically. |
| 20 | + |
| 21 | +## Decision |
| 22 | + |
| 23 | +Eliminate the separate SageMaker image by: |
| 24 | + |
| 25 | +1. **Using relative asset paths** — set Vite `base: "./"` and add `<base href="./">` |
| 26 | + to `index.html`. This makes the compiled frontend work behind any reverse proxy |
| 27 | + without build-time knowledge of the path prefix. |
| 28 | + |
| 29 | +2. **Using relative fetch paths** — the client fetches API routes (sparql, gremlin, |
| 30 | + openCypher, defaultConnection, etc.) via `new URL("../sparql", document.baseURI)` |
| 31 | + instead of constructing absolute URLs from a configured proxy endpoint. The server |
| 32 | + mounts static files at `/explorer` and API routes at `/`, so `../` from the static |
| 33 | + directory always resolves to the API root. |
| 34 | + |
| 35 | +3. **Always routing through the proxy** — remove the `proxyConnection` toggle and |
| 36 | + `url` (proxy endpoint) from the connection model. The client always sends requests |
| 37 | + to the same-origin proxy server. The connection config simplifies to: database |
| 38 | + endpoint, query engine, and optional IAM settings. |
| 39 | + |
| 40 | +4. **Moving SageMaker defaults to runtime** — `process-environment.sh` reads |
| 41 | + `NEPTUNE_NOTEBOOK=true` at container startup and writes port/log-style/SSL |
| 42 | + settings to `.env`. The Dockerfile no longer sets these, allowing the app's |
| 43 | + built-in defaults (port 80, default log style) to apply when the variable is absent. |
| 44 | + |
| 45 | +5. **Publishing dual tags during transition** — CI builds one image and publishes it |
| 46 | + under both the regular tag and the `sagemaker-*` tag, so existing lifecycle scripts |
| 47 | + continue working without modification. |
| 48 | + |
| 49 | +## Consequences |
| 50 | + |
| 51 | +### Positive |
| 52 | + |
| 53 | +- One image to build, test, scan, and publish — halves CI time for Docker. |
| 54 | +- Users no longer need to figure out or configure the proxy server URL. |
| 55 | +- The connection form simplifies to just the database endpoint and auth settings. |
| 56 | +- Deployments behind arbitrary reverse proxies (not just Jupyter) work without |
| 57 | + build-time configuration. |
| 58 | +- Removes ~20 lines of conditional Dockerfile logic and the two-path defaultConnection |
| 59 | + fallback hack in the client. |
| 60 | + |
| 61 | +### Negative |
| 62 | + |
| 63 | +- Relative paths create a fixed contract: the API root is always one directory above |
| 64 | + the static files mount. This is enforced in one place (`server-config.ts`) so drift |
| 65 | + is unlikely but possible. |
| 66 | +- Legacy stored connections (localStorage) need a read-time migration: |
| 67 | + `graphDbUrl = old.proxyConnection ? old.graphDbUrl : old.url`. |
| 68 | +- The `sagemaker-*` tags must be published for several release cycles until existing |
| 69 | + deployed lifecycle scripts are updated. |
| 70 | +- The proxy server must have network access to the target database. Deployments in |
| 71 | + restricted networks (e.g., private subnets without a NAT gateway) cannot reach |
| 72 | + databases outside that network — even if the user's browser previously could via |
| 73 | + direct connections. Users in this scenario need to add network routing. |
| 74 | + |
| 75 | +### Neutral |
| 76 | + |
| 77 | +- `NEPTUNE_NOTEBOOK` remains as a runtime convenience preset (sets port, log style, |
| 78 | + disables SSL). It is not written to `.env` itself — only its side effects are |
| 79 | + applied. |
| 80 | +- Extra environment variables passed by old deployments (`PUBLIC_OR_PROXY_ENDPOINT`, |
| 81 | + `USING_PROXY_SERVER`) are silently ignored — no errors. |
| 82 | + |
| 83 | +## Changes Required |
| 84 | + |
| 85 | +### Dockerfile |
| 86 | + |
| 87 | +- Remove `ARG NEPTUNE_NOTEBOOK` and all conditional ENV logic |
| 88 | +- Remove `GRAPH_EXP_ENV_ROOT_FOLDER` |
| 89 | +- Remove `ENV PROXY_SERVER_HTTP_PORT` and `ENV LOG_STYLE` (defaults from `env.ts`) |
| 90 | +- Keep `EXPOSE 80`, `EXPOSE 443`, `EXPOSE 9250` |
| 91 | + |
| 92 | +### Frontend Build |
| 93 | + |
| 94 | +- `vite.config.ts`: `base: "./"` |
| 95 | +- `index.html`: add `<base href="./">` |
| 96 | + |
| 97 | +### Client Code |
| 98 | + |
| 99 | +- Explorers use `new URL("../sparql", document.baseURI)` etc. |
| 100 | +- `defaultConnection.ts`: single relative fetch, remove SageMaker fallback |
| 101 | +- `RELOAD_URL` becomes `"."` |
| 102 | +- Remove `proxyConnection` and `url` from `ConnectionConfig` |
| 103 | +- `graphDbUrl` is the canonical database URL field |
| 104 | +- `fetchDatabaseRequest.ts`: always send `graph-db-connection-url` header |
| 105 | +- Read-time normalization for legacy data |
| 106 | + |
| 107 | +### Client UI |
| 108 | + |
| 109 | +- Connection form: remove proxy endpoint and proxy toggle, always show "Graph |
| 110 | + Connection URL" field and IAM toggle |
| 111 | +- Connection display components: simplify to `graphDbUrl` |
| 112 | + |
| 113 | +### Server |
| 114 | + |
| 115 | +- `process-environment.sh`: |
| 116 | + - Remove `PUBLIC_OR_PROXY_ENDPOINT` / `USING_PROXY_SERVER` handling |
| 117 | + - When `NEPTUNE_NOTEBOOK=true`: write `PROXY_SERVER_HTTP_PORT=9250` and |
| 118 | + `LOG_STYLE=cloudwatch` to `.env` (respecting explicit overrides), force SSL off |
| 119 | + - Stop writing `NEPTUNE_NOTEBOOK` to `.env` |
| 120 | + |
| 121 | +### CI |
| 122 | + |
| 123 | +- Build one image, publish under regular + `sagemaker-*` tags |
| 124 | +- Remove `--build-arg NEPTUNE_NOTEBOOK=true` step |
| 125 | + |
| 126 | +### Lifecycle Script |
| 127 | + |
| 128 | +Existing lifecycle scripts continue working unchanged — they pull `sagemaker-*` tags |
| 129 | +(now an alias for the regular image) and pass `PUBLIC_OR_PROXY_ENDPOINT` / |
| 130 | +`USING_PROXY_SERVER` env vars which the unified image silently ignores. |
| 131 | + |
| 132 | +The bundled example script in this repo is updated to: |
| 133 | + |
| 134 | +- Pull regular tag instead of `sagemaker-*` |
| 135 | +- Remove `PUBLIC_OR_PROXY_ENDPOINT` and `USING_PROXY_SERVER` from `docker run` |
| 136 | + |
| 137 | +### Documentation |
| 138 | + |
| 139 | +- `docs/references/configuration.md` |
| 140 | +- `docs/guides/deploy-to-ecs-fargate.md` |
| 141 | +- `docs/guides/deploy-to-sagemaker.md` |
| 142 | +- `docs/guides/deploy-with-docker.md` |
| 143 | +- `docs/features/connections.md` |
| 144 | +- `docs/architecture.md` |
0 commit comments