Files
flights_web/deployment/build-docker.sh
T
gnezim 2e2c5c09ce
CI / ci (push) Failing after 30s
Deploy / build-and-deploy (push) Failing after 6s
Fix __ENV__ truncation; route API_BASE_URL through the same injection
Two gaps blocked http://flights-ui.devwebzavod.ru/ru/flights-map:

1. The inline <script>window.__ENV__=...</script> was written with the
   Leaflet tile template ('/map/api/tile/{z}/{x}/{y}.jpeg') embedded
   directly. Rspack's html-plugin pre-processes the children string and
   ate the '{z}' placeholder, truncating the injected JS literal to
   '/map/api/tile/{z' — MAP_TILE_URL on the client ended up broken and
   getEnv() fell back to the default.

   Escape every '{'/'}' inside the stringified value as '\u007B'/'\u007D'.
   JS decodes the Unicode escapes back to '{}' at parse time; the html
   plugin's template engine sees no placeholders to eat. Object-literal
   braces outside the string stay raw (Unicode escapes aren't valid in
   operator positions in JS source).

2. API_BASE_URL was still hard-defaulting to 'http://localhost:8080/api',
   so every dictionary fetch on the deployed cluster died with
   ERR_CONNECTION_REFUSED. Thread API_BASE_URL through the same
   PUBLIC_ENV_KEYS/html.tags path as MAP_TILE_URL, add matching Docker
   ARG/ENV, and forward it in deployment/build-docker.sh + k8s manifest.

The devwebzavod default for both is https://flights.test.aeroflot.ru
— where the real Aeroflot ingress terminates /map/api/** and /api/**.
Prod keeps overriding with same-origin URLs.
2026-04-18 23:56:28 +03:00

32 lines
1.3 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. The defaults match the devwebzavod cluster (no
# /map/api/** or /api/** ingress rule — hit the upstream that the real
# Aeroflot ingress terminates). Prod overrides with same-origin.
: "${MAP_TILE_URL:=https://flights.test.aeroflot.ru/map/api/tile/{z}/{x}/{y}.jpeg}"
: "${API_BASE_URL:=https://flights.test.aeroflot.ru/api}"
export MAP_TILE_URL API_BASE_URL
docker build -t aeroflot.$K8NAMESPACE/$1:v$VERSION.$BUILD_NUMBER \
--build-arg ENVIRONMENT=${ENVIRONMENT} \
--build-arg=NPM_PROXY \
--build-arg MAP_TILE_URL=${MAP_TILE_URL} \
--build-arg API_BASE_URL=${API_BASE_URL} \
-f "$2/Dockerfile" $2
}
build flights-ui "../Aeroflot.Flights.Front"
exit 0