ef85ae6ea1
http://flights-ui.devwebzavod.ru/ru/flights-map was still hitting the same-origin tile path after adding the k8s env: Modern.js renders the <Suspense> fallback on the server (i18n isn't preloaded), so the route component that reads getEnv() never actually runs during SSR. The page hydrates client-side, where process.env is Rspack's empty stub and MAP_TILE_URL is never set — getEnv() falls back to the default. Move the value into window.__ENV__ instead: - modern.config.ts: inline a <script> into html.tags that sets window.__ENV__ = { MAP_TILE_URL: <value> } at SSR-server startup. The snippet is authored once at server boot, so the HTML template baked into dist/standalone/html/main/index.html always carries the pod's tile URL. - src/env/index.ts: merge window.__ENV__ on top of process.env so the browser prefers the injected value (process.env only has NODE_ENV after Rspack's polyfill). - Dockerfile.react: accept MAP_TILE_URL as a build ARG and expose it as ENV before `pnpm build:standalone`, so Modern.js picks it up when building the HTML template. k8s env still flows into the Node SSR process; the build-arg path guarantees correctness even when the runtime env is stripped. - deployment/build-docker.sh: forward MAP_TILE_URL through as a build-arg (default keeps the same-origin path). CI on the devwebzavod cluster can export MAP_TILE_URL=https://flights.test.aeroflot.ru/map/api/tile/{z}/{x}/{y}.jpeg before running build-docker.sh and the resulting image will serve tiles from the upstream the real Aeroflot ingress terminates.
49 lines
1.4 KiB
React
49 lines
1.4 KiB
React
# Dockerfile.react — Multi-stage build for Modern.js SSR standalone app.
|
|
# Coexists with the legacy ASP.NET Dockerfile.
|
|
|
|
FROM node:24-slim AS deps
|
|
WORKDIR /app
|
|
|
|
RUN corepack enable pnpm
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
FROM deps AS build
|
|
WORKDIR /app
|
|
|
|
COPY modern.config.ts module-federation.config.ts tsconfig.json ./
|
|
COPY src/ src/
|
|
# Modern.js publicDir: fonts, images, leaflet marker icons, favicons.
|
|
# Copied into dist/standalone/public/ at build time. Without this the
|
|
# /assets/** URLs resolve to the SPA index HTML (OTS font-parse failures,
|
|
# 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
|
|
ENV MAP_TILE_URL=${MAP_TILE_URL}
|
|
|
|
RUN pnpm build:standalone
|
|
|
|
FROM node:24-slim AS runtime
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=8080
|
|
|
|
RUN corepack enable pnpm
|
|
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/dist/standalone/ ./dist/standalone/
|
|
COPY --from=build /app/src/ ./src/
|
|
COPY package.json modern.config.ts module-federation.config.ts ./
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["pnpm", "exec", "modern", "serve"]
|