-
Notifications
You must be signed in to change notification settings - Fork 74
feat: harden model-engine runtime on chainguard #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1c42de3
feat: harden model-engine runtime on chainguard
scale-ballen e2c5fb3
fix: restore runtime kubectl assets
scale-ballen 54f41f0
fix: tighten runtime binary handling
scale-ballen a79a067
fix: eliminate remaining runtime binary highs
scale-ballen b479214
fix: honor target architecture for runtime binaries
scale-ballen 5f5840f
fix: restore CI test compatibility
scale-ballen 8ea29f9
fix: remove coreutils dependency from migration script
scale-ballen 8eabec0
fix: use shell-based readiness probes
scale-ballen 84a1045
fix: remove endpoint builder shell dependencies
scale-ballen f871d5e
style: format remote build helper
scale-ballen fea67a9
fix: normalize endpoint build context paths
scale-ballen b1d2c94
fix: use writable build context temp dirs
scale-ballen 13f827f
fix: unblock simple bundle endpoint builds
scale-ballen 56e57a0
test: cover remote build diff paths
scale-ballen 6637e6e
test: fix remote build credential assertion
scale-ballen 1da90cb
fix: address review feedback on build context handling
scale-ballen f4261c8
fix: keep temp build contexts out of archives
scale-ballen 42699f1
fix: avoid archiving temp build contexts
scale-ballen 9b4686e
fix: address runtime library and ignore matching reviews
scale-ballen 86f894a
fix: restore root-only ignore glob behavior
scale-ballen b2cb597
test: align archive ignore coverage with matcher semantics
scale-ballen 823f556
fix: skip rewriting build context root args
scale-ballen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,79 +1,70 @@ | ||
| # syntax = docker/dockerfile:experimental | ||
| # syntax = docker/dockerfile:1 | ||
|
|
||
| # --- Builder: compile C extensions (pycurl, etc.) and install Python packages --- | ||
| FROM python:3.13-slim AS builder | ||
| FROM cgr.dev/chainguard/python:latest-dev AS builder | ||
|
|
||
| USER root | ||
| WORKDIR /workspace | ||
| ARG TARGETARCH | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| RUN apk add --no-cache \ | ||
| bash \ | ||
| build-base \ | ||
| curl \ | ||
| curl-dev \ | ||
| dumb-init \ | ||
| git \ | ||
| gcc \ | ||
| build-essential \ | ||
| libssl-dev \ | ||
| libcurl4-openssl-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| go \ | ||
| openssl-dev \ | ||
| rsync | ||
|
|
||
| RUN pip install pip==24.2 setuptools | ||
| RUN pip install awscli==1.34.28 --no-cache-dir | ||
| RUN python -m venv /workspace/venv | ||
| ENV PATH="/workspace/venv/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
|
|
||
| WORKDIR /workspace/model-engine/ | ||
| COPY model-engine/requirements-test.txt requirements-test.txt | ||
| WORKDIR /workspace/model-engine | ||
| COPY model-engine/requirements.txt requirements.txt | ||
| COPY model-engine/requirements_override.txt requirements_override.txt | ||
| RUN pip install -r requirements-test.txt --no-cache-dir | ||
| RUN pip install -r requirements.txt --no-cache-dir | ||
| # NOTE: aioboto3==10.4.0 -> aiobotocore==2.4.2 -> urllib3<1.27, which downgrades urllib3 | ||
| # from 2.x back to 1.26.x. CVE-2023-43804, CVE-2023-45803, CVE-2024-37891 remain. | ||
| # Fix: upgrade aioboto3 to >=15.x (separate PR — breaking API changes). | ||
| RUN pip install --upgrade pip==24.2 setuptools cmake setuptools-rust | ||
| RUN pip install -r requirements.txt --no-cache-dir --no-build-isolation | ||
| RUN pip install -r requirements_override.txt --no-cache-dir | ||
| COPY model-engine/setup.py setup.py | ||
| COPY model-engine/model_engine_server model_engine_server | ||
| COPY model-engine/service_configs service_configs | ||
| RUN pip install -e . | ||
|
|
||
| # --- Runtime: no build tools (eliminates linux-libc-dev and python3.13 CVEs) --- | ||
| FROM python:3.13-slim AS model-engine | ||
|
|
||
| WORKDIR /workspace | ||
|
|
||
| # Runtime-only system deps (vim omitted: multiple unpatched HIGH CVEs in Debian 13.4) | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| dumb-init \ | ||
| git \ | ||
| openssh-client \ | ||
| curl \ | ||
| procps \ | ||
| htop \ | ||
| libcurl4 \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install aws-iam-authenticator (architecture-aware) | ||
| RUN ARCH=$(uname -m) && \ | ||
| if [ "$ARCH" = "aarch64" ]; then \ | ||
| curl -fLo /bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.7.11/aws-iam-authenticator_0.7.11_linux_arm64; \ | ||
| else \ | ||
| curl -fLo /bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.7.11/aws-iam-authenticator_0.7.11_linux_amd64; \ | ||
| fi && \ | ||
| chmod +x /bin/aws-iam-authenticator | ||
| RUN mkdir -p /tmp/runtime-bin /tmp/runtime-libs && \ | ||
| cp /bin/bash /tmp/runtime-bin/bash && \ | ||
| cp /usr/bin/dumb-init /tmp/runtime-bin/dumb-init && \ | ||
| cp /usr/bin/git /tmp/runtime-bin/git && \ | ||
| cp -R /usr/libexec/git-core /tmp/runtime-bin/git-core && \ | ||
| cp /usr/lib/libpcre2-8.so.0* /tmp/runtime-libs/ && \ | ||
| cp /usr/lib/libcurl.so.4* /tmp/runtime-libs/ && \ | ||
| cp /usr/lib/libreadline.so.8* /tmp/runtime-libs/ && \ | ||
| cp /usr/lib/libtinfo.so.6* /tmp/runtime-libs/ && \ | ||
| cp /usr/lib/libz.so.1* /tmp/runtime-libs/ && \ | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| git clone --depth 1 --branch v1.35.3 https://github.com/kubernetes/kubernetes.git /tmp/k8s && \ | ||
| cd /tmp/k8s && \ | ||
| GOTOOLCHAIN=local KUBE_BUILD_PLATFORMS=linux/${TARGETARCH} make WHAT=cmd/kubectl && \ | ||
| cp _output/local/bin/linux/${TARGETARCH}/kubectl /tmp/runtime-bin/kubectl && \ | ||
| GOBIN=/tmp/runtime-bin GOOS=linux GOARCH=${TARGETARCH} go install sigs.k8s.io/aws-iam-authenticator/cmd/aws-iam-authenticator@v0.7.11 | ||
|
|
||
| # Install kubectl (architecture-aware) | ||
| RUN ARCH=$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') && \ | ||
| curl -fLO "https://dl.k8s.io/release/v1.35.3/bin/linux/${ARCH}/kubectl" && \ | ||
| chmod +x kubectl && \ | ||
| mv kubectl /usr/local/bin/kubectl | ||
| FROM cgr.dev/chainguard/python:latest AS model-engine | ||
|
|
||
| # Copy Python packages, entry-point scripts, and source tree from builder | ||
| COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages | ||
| COPY --from=builder /usr/local/bin /usr/local/bin | ||
| COPY --from=builder /workspace/model-engine /workspace/model-engine | ||
|
|
||
| RUN useradd --create-home --shell /bin/bash nonroot && \ | ||
| chown -R nonroot:nonroot /workspace | ||
| USER root | ||
| WORKDIR /workspace | ||
|
|
||
| COPY integration_tests /workspace/integration_tests | ||
| COPY --from=builder --chown=nonroot:nonroot /workspace/venv /workspace/venv | ||
| COPY --from=builder --chown=nonroot:nonroot /workspace/model-engine /workspace/model-engine | ||
| COPY --from=builder /tmp/runtime-bin/bash /bin/bash | ||
| COPY --from=builder /tmp/runtime-bin/dumb-init /usr/bin/dumb-init | ||
| COPY --from=builder /tmp/runtime-bin/git /usr/bin/git | ||
| COPY --from=builder /tmp/runtime-bin/git-core /usr/libexec/git-core | ||
| COPY --from=builder /tmp/runtime-bin/kubectl /usr/local/bin/kubectl | ||
| COPY --from=builder /tmp/runtime-bin/aws-iam-authenticator /usr/local/bin/aws-iam-authenticator | ||
| COPY --from=builder /tmp/runtime-libs/ /usr/lib/ | ||
|
|
||
| WORKDIR /workspace | ||
| ENV PYTHONPATH /workspace | ||
| ENV WORKSPACE /workspace | ||
| ENV PATH="/workspace/venv/bin:/usr/local/bin:/usr/libexec/git-core:/usr/bin:/bin" | ||
| ENV PYTHONPATH=/workspace | ||
| ENV WORKSPACE=/workspace | ||
|
|
||
| USER nonroot | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| EXPOSE 5000 | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.