Fix URL truncation from bash \${VAR:=default} with braces
Deployed build had MAP_TILE_URL truncated to 'https://.../tile/{z' — Leaflet then URL-encoded it to '%7Bz' and fetched garbage tile paths. Root cause: build-docker.sh used : "\${MAP_TILE_URL:=https://flights.test.aeroflot.ru/map/api/tile/{z}/{x}/{y}.jpeg}" and bash parameter expansion terminates the default value at the FIRST unescaped '}', leaving '{z' and discarding the rest. The env passed to `pnpm build:standalone` was already truncated, so every downstream step (base64 encode → HTML inject → client decode) faithfully carried the broken value through. Fix by moving the defaults to Dockerfile's ARG lines — ARG defaults are plain strings, not shell-parsed — and simplify build-docker.sh to only forward MAP_TILE_URL / API_BASE_URL as --build-arg when the caller explicitly sets them. Quote the k8s env values for defensive YAML hygiene as well.
This commit is contained in:
+13
-6
@@ -20,13 +20,20 @@ COPY src/ src/
|
||||
# broken backgrounds, missing tile icons).
|
||||
COPY config/ config/
|
||||
|
||||
# Runtime-tunable env vars. modern.config.ts reads these when Modern.js
|
||||
# boots the SSR server at container start, so values set via k8s env
|
||||
# propagate without a rebuild. The ARG line lets CI also bake a value
|
||||
# into the image if the cluster can't set env at runtime.
|
||||
ARG MAP_TILE_URL
|
||||
# Public env values baked into dist/standalone/html/main/index.html by
|
||||
# modern.config.ts at build time. Defaults target the devwebzavod cluster
|
||||
# (no /map/api/** or /api/** ingress rule → hit the upstream that the
|
||||
# real Aeroflot ingress terminates). Production overrides via
|
||||
# --build-arg, e.g.
|
||||
# --build-arg MAP_TILE_URL=/map/api/tile/{z}/{x}/{y}.jpeg
|
||||
# --build-arg API_BASE_URL=/api
|
||||
# Defaults live here rather than in deployment/build-docker.sh because
|
||||
# bash `${VAR:=default}` stops at the first unescaped `}` — the literal
|
||||
# `{z}/{x}/{y}` in the URL was being truncated to `{z`. Dockerfile ARG
|
||||
# defaults are plain strings, no shell parsing.
|
||||
ARG MAP_TILE_URL=https://flights.test.aeroflot.ru/map/api/tile/{z}/{x}/{y}.jpeg
|
||||
ENV MAP_TILE_URL=${MAP_TILE_URL}
|
||||
ARG API_BASE_URL
|
||||
ARG API_BASE_URL=https://flights.test.aeroflot.ru/api
|
||||
ENV API_BASE_URL=${API_BASE_URL}
|
||||
|
||||
RUN pnpm build:standalone
|
||||
|
||||
Reference in New Issue
Block a user