Skip to content

Minimize and security-gate the Junos MCP container - #31

Open
tbelz wants to merge 5 commits into
Juniper:mainfrom
tbelz:codex/container-security-baseline
Open

tbelz wants to merge 5 commits into
Juniper:mainfrom
tbelz:codex/container-security-baseline

Conversation

@tbelz

@tbelz tbelz commented Aug 5, 2026 •

Copy link
Copy Markdown

Summary

  • replaces the tools-heavy Debian image with a non-root, multi-stage Python 3.11 Alpine runtime
  • installs exactly the existing uv.lock in frozen mode and removes unused ping, traceroute, and general networking utilities while retaining SSH for PyEZ ProxyCommand operation
  • preserves PyEZ/ncclient, health checks, stdio transport, configuration, and the NITA integration contract
  • adds native amd64/arm64 builds, smoke tests, complete Trivy reporting, and a blocking unaccepted-CRITICAL gate in the source repository

Cross-repository design authority:
https://github.com/tbelz/nita/tree/codex/container-security-baseline/openspec/changes/archive/2026-08-05-enforce-container-security-baseline

Tracks Juniper/nita#75. The supported boundary remains a locally operated trusted lab, not an internet-facing or multi-tenant deployment.

Validation

  • frozen uv sync, Python compile checks, and 52 unit tests
  • native ARM non-root runtime, import, health, and SSH smoke tests
  • native amd64 and arm64 fork jobs
  • Trivy 0.69.3: 18 HIGH records and 0 CRITICAL records
  • actionlint and YAML validation

@nileshsimaria

Copy link
Copy Markdown
Collaborator

@tbelz thanks for the MR. One comment: The Dockerfile rebuilds all dependencies every time there is a change the code.

Docker builds an image step by step, and it caches each step. If nothing a step depends on has changed, Docker skips it and reuses the cached result. But the moment one step's inputs change, that step and every step after it must re-run.

What the PR does: In the builder stage, the steps are in this order:

  1. Copy pyproject.toml and uv.lock (the dependency list)
  2. Copy jmcp.py, utils/, block.cmd, block.cfg (the application source code)
  3. Run uv sync (download and install all Python dependencies — the slow step, it even compiles some packages from source)

The problem: Because the source code is copied before the install step, editing even one line of jmcp.py invalidates step 2, which forces step 3 to re-run — meaning a full re-download and re-compile of every dependency, even though the dependencies didn't change at all.

The fix: The install step only needs pyproject.toml and uv.lock — it never reads the source code (that's what the --no-install-project flag means). So copy only those two files into the builder stage, run the install, and copy the source code into the final image directly from your project folder. Then a code change only re-runs the cheap "copy files" step, and the expensive dependency install stays cached.

Can you take care of above ?

@nileshsimaria
nileshsimaria self-requested a review August 10, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants