Stage all root-sourced mirrored docs in Docker frontend builds

PR #5420 (b250914857) updated frontend-modern/scripts/sync-public-docs.mjs
to sync every mirrored markdown file under frontend-modern/public/docs/
during npm run build, including all four ROOT_SOURCED_DOCS (SECURITY.md,
TERMS.md, ARCHITECTURE.md, CONTRIBUTING.md). Both .dockerignore and the
frontend-builder stages in Dockerfile and
deploy/provider-msp/Dockerfile.control-plane still staged only SECURITY.md
and TERMS.md, breaking Core E2E image builds (main runs 46184827492 and
46185958697, PR #5439 job 141102369291) and source Docker builds with
ENOENT on /app/ARCHITECTURE.md.

- .dockerignore: allow ARCHITECTURE.md and CONTRIBUTING.md alongside
  SECURITY.md and TERMS.md.
- Dockerfile and deploy/provider-msp/Dockerfile.control-plane: copy
  ARCHITECTURE.md and CONTRIBUTING.md into /app/ in frontend-builder
  before npm run build, preserving the existing COPY SECURITY.md TERMS.md
  /app/ line checked by installtests.
- scripts/tests/test_container_packaging.py: add a regression test
  verifying .dockerignore and both frontend-builder Dockerfiles stage
  every root-sourced doc from scripts/check_docs_mirror.py and executing
  frontend-modern/scripts/sync-public-docs.mjs inside the resulting
  simulated container layout (with a missing-file negative control).

Contract-Neutral: Build-context and Dockerfile staging repair restoring container builds after #5420; no public interface or subsystem contract change.
Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-11-28 20:27:29 +00:00
parent 121f890c77
commit 5be27bffba
4 changed files with 109 additions and 0 deletions
+2
View File
@@ -10,6 +10,8 @@ dev-docs/
!docs/**
!SECURITY.md
!TERMS.md
!ARCHITECTURE.md
!CONTRIBUTING.md
# Binaries and build artifacts
pulse
+1
View File
@@ -18,6 +18,7 @@ COPY frontend-modern/ ./
COPY scripts/exclusive-lock.mjs /app/scripts/exclusive-lock.mjs
COPY docs/ /app/docs/
COPY SECURITY.md TERMS.md /app/
COPY ARCHITECTURE.md CONTRIBUTING.md /app/
# Build frontend
RUN --mount=type=cache,id=pulse-npm-cache,target=/root/.npm \
@@ -9,6 +9,7 @@ COPY frontend-modern/ ./
COPY scripts/exclusive-lock.mjs /app/scripts/exclusive-lock.mjs
COPY docs/ /app/docs/
COPY SECURITY.md TERMS.md /app/
COPY ARCHITECTURE.md CONTRIBUTING.md /app/
RUN --mount=type=cache,id=pulse-control-plane-npm-cache,target=/root/.npm \
npm run build
+105
View File
@@ -8,6 +8,7 @@ import importlib.util
import io
import json
import os
import shutil
import subprocess
import tarfile
import tempfile
@@ -302,6 +303,110 @@ class DockerfileTests(unittest.TestCase):
self.assertEqual(path.read_bytes(), before[path])
self.assertEqual(path.stat().st_mode & 0o777, 0o755 if executable else 0o644)
def test_frontend_builder_stages_every_mirrored_doc_source(self):
# Verify .dockerignore and every frontend-building Dockerfile stage all
# mirrored doc sources that sync-public-docs.mjs reads during npm run build.
mirror_spec = importlib.util.spec_from_file_location(
'check_docs_mirror', ROOT/'scripts/check_docs_mirror.py'
)
check_docs_mirror = importlib.util.module_from_spec(mirror_spec)
mirror_spec.loader.exec_module(check_docs_mirror)
expected_root_docs = set(check_docs_mirror.ROOT_SOURCED_DOCS)
self.assertTrue(expected_root_docs)
ignore_lines = [
line.strip()
for line in (ROOT/'.dockerignore').read_text().splitlines()
if line.strip() and not line.strip().startswith('#')
]
self.assertIn('*.md', ignore_lines)
md_idx = ignore_lines.index('*.md')
allowed_root_md = {
line[1:]
for line in ignore_lines[md_idx + 1:]
if line.startswith('!') and '/' not in line[1:] and line.endswith('.md')
}
self.assertTrue(
expected_root_docs.issubset(allowed_root_md),
f'.dockerignore missing root-sourced doc allowlist entries: '
f'{sorted(expected_root_docs - allowed_root_md)}',
)
self.assertIn('!docs/', ignore_lines)
self.assertIn('!docs/**', ignore_lines)
for df_path in (ROOT/'Dockerfile', ROOT/'deploy/provider-msp/Dockerfile.control-plane'):
with self.subTest(dockerfile=df_path.relative_to(ROOT).as_posix()):
text = df_path.read_text().replace('\\\n', '')
stage_lines = []
in_frontend = False
for raw in text.splitlines():
line = raw.strip()
if line.startswith('FROM '):
in_frontend = line.endswith(' AS frontend-builder')
continue
if not in_frontend or not line or line.startswith('#'):
continue
if line.startswith('RUN ') and 'npm run build' in line:
break
stage_lines.append(line)
copied_docs_dir = False
copied_root_md = set()
for line in stage_lines:
if not line.startswith('COPY '):
continue
args = [p for p in line.split()[1:] if not p.startswith('--')]
if len(args) < 2:
continue
srcs, dst = args[:-1], args[-1]
if dst == '/app/docs/' and 'docs/' in srcs:
copied_docs_dir = True
if dst == '/app/':
for src in srcs:
if src.endswith('.md') and '/' not in src:
copied_root_md.add(src)
self.assertTrue(copied_docs_dir, f'{df_path.name} frontend-builder must COPY docs/ /app/docs/')
self.assertTrue(
expected_root_docs.issubset(copied_root_md),
f'{df_path.name} frontend-builder missing COPY to /app/ for: '
f'{sorted(expected_root_docs - copied_root_md)}',
)
with tempfile.TemporaryDirectory() as tmp:
app = Path(tmp)/'app'
fm = app/'frontend-modern'
(fm/'scripts').mkdir(parents=True)
shutil.copy2(
ROOT/'frontend-modern/scripts/sync-public-docs.mjs',
fm/'scripts/sync-public-docs.mjs',
)
shutil.copytree(ROOT/'frontend-modern/public/docs', fm/'public/docs')
shutil.copytree(ROOT/'docs', app/'docs')
for doc in sorted(copied_root_md & allowed_root_md):
shutil.copy2(ROOT/doc, app/doc)
ok = subprocess.run(
['node', str(fm/'scripts/sync-public-docs.mjs')],
cwd=fm,
text=True,
capture_output=True,
check=False,
)
self.assertEqual(ok.returncode, 0, ok.stderr or ok.stdout)
self.assertIn('(0 updated,', ok.stdout)
(app/'ARCHITECTURE.md').unlink()
missing = subprocess.run(
['node', str(fm/'scripts/sync-public-docs.mjs')],
cwd=fm,
text=True,
capture_output=True,
check=False,
)
self.assertNotEqual(missing.returncode, 0)
self.assertIn('ARCHITECTURE.md', missing.stderr + missing.stdout)
if __name__ == '__main__':
unittest.main()