d43bfb3fcb
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.
38 lines
1.4 KiB
Bash
38 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
echo -e "\E[1;34mCleanup docker build cache to reduce disk usage\E[1;0m"
|
|
docker image prune -f
|
|
docker container prune -f
|
|
|
|
function build {
|
|
K8NAMESPACE="flights-ui"
|
|
echo -e "\E[1;34mBuilding $2 ($1)\E[1;0m"
|
|
export CopyRetryCount=100
|
|
docker rmi -f $(docker images aeroflot.$K8NAMESPACE/$1 -a -q|uniq) >/dev/null 2>/dev/null
|
|
ls -l "$2/Dockerfile"
|
|
# MAP_TILE_URL / API_BASE_URL must flow as build-args (not just runtime
|
|
# env) because Modern.js bakes html.tags into the HTML template at
|
|
# `pnpm build:standalone` time. Values set only on the pod don't change
|
|
# the served HTML. Defaults for both live in Dockerfile's ARG lines —
|
|
# keeping them there avoids bash `${VAR:=default}` parsing the `{z}/
|
|
# {x}/{y}` pattern as balanced braces (it stops at the first `}` and
|
|
# truncates the URL to `/tile/{z`). CI can still override by exporting
|
|
# MAP_TILE_URL / API_BASE_URL before running this script.
|
|
docker_args=(
|
|
--build-arg "ENVIRONMENT=${ENVIRONMENT}"
|
|
--build-arg=NPM_PROXY
|
|
)
|
|
if [ -n "${MAP_TILE_URL:-}" ]; then
|
|
docker_args+=(--build-arg "MAP_TILE_URL=${MAP_TILE_URL}")
|
|
fi
|
|
if [ -n "${API_BASE_URL:-}" ]; then
|
|
docker_args+=(--build-arg "API_BASE_URL=${API_BASE_URL}")
|
|
fi
|
|
docker build -t "aeroflot.$K8NAMESPACE/$1:v$VERSION.$BUILD_NUMBER" \
|
|
"${docker_args[@]}" \
|
|
-f "$2/Dockerfile" "$2"
|
|
}
|
|
|
|
build flights-ui "../Aeroflot.Flights.Front"
|
|
|
|
exit 0 |