Propagate Modern.js publicDir assets through sync + Docker build

The config/public/ directory (fonts, images, leaflet icons, favicons) is
Modern.js's publicDir convention — copied into dist/standalone/public/ at
build time. Two pre-existing gaps caused this to break on the deployed
SSR image and any fresh sync:

- scripts/sync-to-flights-front.sh did not copy config/ to the target
  repo, so the flights-front tree was missing /assets/** entirely.
- Dockerfile.react only copied src/, skipping config/; pnpm
  build:standalone ran without a publicDir source.

Result was that every /assets/** URL served the SSR HTML index with
Content-Type: text/html, producing OTS font-parse errors
(sfntVersion 1008821359 == '<!DT') and silently broken images.

Fix mirrors what was applied ad-hoc in Aeroflot.Flights.Front; this makes
future syncs and Docker builds carry the assets automatically.
This commit is contained in:
2026-04-17 17:18:51 +03:00
parent 10dfc8609d
commit 2ae59d2074
2 changed files with 20 additions and 6 deletions
+15 -6
View File
@@ -1,7 +1,6 @@
# Dockerfile.react Multi-stage build for standalone SSR server
# Coexists with the legacy ASP.NET Dockerfile
# Dockerfile.react Multi-stage build for Modern.js SSR standalone app.
# Coexists with the legacy ASP.NET Dockerfile.
# Stage 1: Install dependencies
FROM node:24-slim AS deps
WORKDIR /app
@@ -10,23 +9,33 @@ RUN corepack enable pnpm
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Stage 2: Build standalone target
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/
RUN pnpm build:standalone
# Stage 3: Minimal production image
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
ENTRYPOINT ["node", "dist/standalone/index.js"]
CMD ["pnpm", "exec", "modern", "serve"]
+5
View File
@@ -35,6 +35,10 @@ echo "2/5 Copying source files..."
cp -r "$SRC_DIR/src" "$TARGET_DIR/src"
cp -r "$SRC_DIR/tests" "$TARGET_DIR/tests"
cp -r "$SRC_DIR/scripts" "$TARGET_DIR/scripts"
# Modern.js publicDir — fonts, images, leaflet icons, favicons. Copied to
# dist/standalone/public/ at build time. Without these the app serves the
# SPA index for /assets/** and breaks @font-face, img references, tile icons.
cp -r "$SRC_DIR/config" "$TARGET_DIR/config"
cp "$SRC_DIR/package.json" "$TARGET_DIR/package.json"
cp "$SRC_DIR/pnpm-lock.yaml" "$TARGET_DIR/pnpm-lock.yaml"
cp "$SRC_DIR/tsconfig.json" "$TARGET_DIR/tsconfig.json"
@@ -45,6 +49,7 @@ cp "$SRC_DIR/playwright.config.ts" "$TARGET_DIR/playwright.config.ts"
cp "$SRC_DIR/eslint.config.js" "$TARGET_DIR/eslint.config.js"
cp "$SRC_DIR/Makefile" "$TARGET_DIR/Makefile"
cp "$SRC_DIR/CLAUDE.md" "$TARGET_DIR/CLAUDE.md"
cp "$SRC_DIR/AGENTS.md" "$TARGET_DIR/AGENTS.md"
# Dockerfile — use the SSR-specific one
cp "$SRC_DIR/Dockerfile.react" "$TARGET_DIR/Dockerfile"