feat: harden model-engine runtime on chainguard#809
Merged
scale-ballen merged 22 commits intomainfrom Apr 20, 2026
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
lilyz-ai
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
model-enginefrompython:3.13-slimto public Chainguardpython:latest-dev/python:latestgitexecutable and shared libraries into the minimal runtime imageWhat Changed
model-engine/Dockerfilecgr.dev/chainguard/python:latest-devcgr.dev/chainguard/python:latestapt-getflow withapkin the builder stageservice_configsinto the image so the gateway startup path can resolveservice_config_circleci.yamlgit,git-core, and the required runtime libraries (libpcre2-8,libz) from the builder stage into the final image so GitPython-backed startup imports still workmodel-engine/requirements.inddtraceto>=4.7.1,<5.0numpyto>=2.4.4,<2.5google-cloud-artifact-registryto~=1.21.0psycopg2-binaryto2.9.11pytz>=2024.1pydanticto2.12.5model-engine/requirements.txtddtrace 4.7.1envier 0.6.1numpy 2.4.4grpcio 1.75.1grpcio-status 1.75.1protobuf 6.33.5google-cloud-artifact-registry 1.21.0psycopg2-binary 2.9.11pytz 2025.2pydantic 2.12.5pydantic-core 2.41.5Why
The previous
model-engineimage was based onpython:3.13-slimand carried a large Debian OS vulnerability surface. Moving to the public Chainguard Python images materially reduces OS exposure, but because public Chainguard currently tracks Python 3.14, the repo also needed a coordinated dependency refresh to restore build and runtime compatibility.The runtime boot path also imports GitPython-backed ECR helpers during gateway startup. A minimal runtime image therefore still needs the
gitexecutable and its required shared libraries present, even though the rest of the image is aggressively minimized.Validation
Build-time
docker build --platform linux/amd64 --progress=plain -f model-engine/Dockerfile -t llm-engine-chainguard-min:local .Runtime
import model_engine_serverproduction-developerAWS profile and explicit local test env:GIT_TAG=testCIRCLECI=trueAWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKENGET /healthzreturned200Security scan
trivy image --scanners vuln --severity CRITICAL,HIGH --format json -o /tmp/llm-engine-chainguard-min-final-trivy.json llm-engine-chainguard-min:local0 CRITICAL0 HIGHNotes
ddtracewarning about Pydantic v1 functionality on Python 3.14/healthzcheck.Greptile Summary
This PR migrates the
model-engineruntime frompython:3.13-slimto the Chainguardpython:latest-dev/python:latestimage pair, achieving a 0 CRITICAL / 0 HIGH Trivy result, and coordinates a full Python 3.14-compatible dependency refresh (ddtrace 4.7.1, pydantic 2.12.5, protobuf 6.33.5, grpcio 1.75.1, numpy 2.4.4). It also refactors the remote Docker-build pipeline with cleaner archive filtering, a proper path-normalization helper for build args, and new unit-test coverage for previously untested helpers.The prior round of review flagged several regressions that are now resolved —
kubectlis built from source and copied into the runtime,libcurl/libreadline/libtinfoare collected alongsidelibz/libpcre2,TARGETARCHis threaded through both Go compilation steps, and thelstrip("./")dotfile-mangling bug is fixed withremoveprefix. TheBUILD_CONTEXT_TEMP_ROOTbeing placed insidemodel-engine/(so accumulated temp dirs are included in every subsequent build archive) remains unaddressed from the prior round.Confidence Score: 4/5
Safe to merge once the BUILD_CONTEXT_TEMP_ROOT leakage concern from the prior review is resolved; all other previously flagged regressions (kubectl, libcurl, libreadline, TARGETARCH, lstrip) are now fixed.
All new-round findings are P2 or lower. The one open P1 (BUILD_CONTEXT_TEMP_ROOT inside model-engine/ causing cumulative archive pollution and potential bundle leakage across builds) was raised in the prior review thread and is not yet addressed in this revision, preventing a 5.
model-engine/model_engine_server/infra/services/live_endpoint_builder_service.py (BUILD_CONTEXT_TEMP_ROOT placement), model-engine/Dockerfile (builder stage pulls the entire Kubernetes repo to compile kubectl — very long build times)
Important Files Changed
Sequence Diagram
sequenceDiagram participant EB as EndpointBuilder Pod (Chainguard runtime) participant S3 as S3 participant K8s as Kubernetes API participant Kaniko as Kaniko Pod EB->>EB: _create_build_context_dir() under WORKSPACE/model-engine/.build-context/ EB->>EB: _normalize_build_args() rewrite abs paths to relative EB->>EB: zip_context() _filter_archive_member() excludes nested roots and ignore patterns EB->>S3: upload tar.gz build context EB->>K8s: kubectl patch secret codeartifact-pip-conf EB->>K8s: kubectl apply -f kaniko-job.yaml K8s->>Kaniko: start Kaniko pod Kaniko->>S3: download tar.gz context Kaniko->>Kaniko: docker build and push to ECR EB->>K8s: watch pod status (kubernetes Python client) K8s-->>EB: pod Succeeded/Failed EB->>K8s: kubectl logs (read final build output)Reviews (22): Last reviewed commit: "fix: skip rewriting build context root a..." | Re-trigger Greptile