Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions deploy/docker/Dockerfile.konflux.cli
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
# CLI image for RHEL/Konflux (hermetic build).
#
# Multi-stage build that compiles the openshell CLI from source on UBI9 as a
# fully-static binary. It is built against glibc with
# `-C target-feature=+crt-static` using Red Hat's glibc-static package
# (CodeReady Builder), so the build has no dependency on musl.
# dynamically linked glibc binary, matching the runtime image's libc and NSS
# modules.
#
# Requires prefetched dependencies via Hermeto (cargo, rpm, generic).
# See deploy/konflux/ for prefetch configs.
Expand All @@ -18,7 +17,7 @@
ARG RUST_VERSION=1.95.0

# ---------------------------------------------------------------------------
# Build stage: compile CLI (fully-static glibc binary)
# Build stage: compile CLI (dynamically linked glibc binary)
# ---------------------------------------------------------------------------
FROM registry.access.redhat.com/ubi9/ubi:9.8@sha256:25a147defd01e19674714f55d17538c8dbe55d8c305fa157ecc3f9c8977b05b6 AS builder

Expand All @@ -27,7 +26,6 @@ ARG TARGETARCH

RUN dnf install -y --nodocs \
gcc gcc-c++ make cmake \
glibc-static \
openssl-devel git-core xz \
&& dnf clean all

Expand Down Expand Up @@ -58,17 +56,18 @@ RUN sed -i 's|members = \["crates/\*"\]|members = ["crates/openshell-cli", "crat
# pass the git tag with the leading "v" stripped. Empty otherwise.
ARG OPENSHELL_VERSION=""

# `-C target-feature=+crt-static` links glibc statically, producing a
# fully-static (static-PIE) binary with no runtime libc dependency.
RUN . /tmp/build-env && \
VER="${OPENSHELL_VERSION#v}" && \
if [ -n "$VER" ]; then export OPENSHELL_GIT_VERSION="$VER"; fi && \
RUSTFLAGS="-C target-feature=+crt-static" \
cargo build --release \
--target "${RUST_TARGET}" \
--package openshell-cli && \
mkdir -p /build/output && \
cp /build/target/${RUST_TARGET}/release/openshell /build/output/
cp /build/target/${RUST_TARGET}/release/openshell /build/output/ && \
readelf -l /build/output/openshell > /tmp/program-headers && \
if ! grep -q 'Requesting program interpreter' /tmp/program-headers; then \
echo "openshell is not dynamically linked" >&2; exit 1; \
fi

# ---------------------------------------------------------------------------
# Runtime
Expand All @@ -84,8 +83,8 @@ RUN update-crypto-policies --set DEFAULT:PQ
COPY --from=builder --chmod=0555 /build/output/openshell /usr/local/bin/openshell

LABEL com.redhat.component="odh-openshell-cli-container" \
description="Statically linked (glibc) CLI for OpenShell sandboxed AI agent runtimes" \
summary="Statically linked (glibc) CLI for OpenShell sandboxed AI agent runtimes" \
description="OpenShell CLI for sandboxed AI agent runtimes" \
summary="OpenShell CLI for sandboxed AI agent runtimes" \
name="rhoai/odh-openshell-cli-rhel9" \
maintainer="['managed-open-data-hub@redhat.com']" \
io.openshift.expose-services="" \
Expand Down
5 changes: 4 additions & 1 deletion deploy/docker/Dockerfile.konflux.sandbox
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ COPY Cargo.toml Cargo.lock ./
COPY .cargo/ .cargo/
COPY crates/ crates/
COPY proto/ proto/
COPY deploy/konflux/sandbox/nss-static.c deploy/konflux/sandbox/nss-static.c

# Version stamped into the binary via openshell-core::VERSION; tag builds
# pass the git tag with the leading "v" stripped. Empty otherwise.
Expand All @@ -67,7 +68,9 @@ ARG OPENSHELL_VERSION=""
RUN . /tmp/build-env && \
VER="${OPENSHELL_VERSION#v}" && \
if [ -n "$VER" ]; then export OPENSHELL_GIT_VERSION="$VER"; fi && \
RUSTFLAGS="-C target-feature=+crt-static" \
gcc -std=c11 -Wall -Wextra -Werror -c \
deploy/konflux/sandbox/nss-static.c -o /tmp/nss-static.o && \
RUSTFLAGS="-C target-feature=+crt-static -C link-arg=/tmp/nss-static.o" \
cargo build --release \
--target "${RUST_TARGET}" \
--package openshell-sandbox \
Expand Down
22 changes: 9 additions & 13 deletions deploy/docker/Dockerfile.konflux.supervisor
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#
# The supervisor runs in its own container, outside the agent workload. The
# workload-side runtime ships separately in Dockerfile.konflux.sandbox. The
# binary is built against glibc with `-C target-feature=+crt-static` using Red
# Hat's glibc-static package (CodeReady Builder), so the build has no
# dependency on musl.
# binary is dynamically linked against the runtime image's glibc.
#
# Requires prefetched dependencies via Hermeto (cargo, rpm, generic).
# See deploy/konflux/ for prefetch configs.
Expand All @@ -19,7 +17,7 @@
ARG RUST_VERSION=1.95.0

# ---------------------------------------------------------------------------
# Build stage: compile supervisor (fully-static glibc binary)
# Build stage: compile supervisor (dynamically linked glibc binary)
# ---------------------------------------------------------------------------
FROM registry.access.redhat.com/ubi9/ubi:9.8@sha256:25a147defd01e19674714f55d17538c8dbe55d8c305fa157ecc3f9c8977b05b6 AS builder

Expand All @@ -28,7 +26,6 @@ ARG TARGETARCH

RUN dnf install -y --nodocs --setopt=install_weak_deps=0 \
gcc gcc-c++ make cmake \
glibc-static \
openssl-devel git-core xz \
&& dnf clean all

Expand All @@ -54,9 +51,6 @@ COPY proto/ proto/
# pass the git tag with the leading "v" stripped. Empty otherwise.
ARG OPENSHELL_VERSION=""

# `-C target-feature=+crt-static` links glibc statically, producing a
# fully-static (static-PIE) binary with no runtime libc dependency.
#
# The alias re-adds `bundled-ca-roots`, which a bare `--no-default-features`
# would drop, keeping the supervisor on the same trust roots as upstream.
#
Expand All @@ -67,15 +61,18 @@ ARG OPENSHELL_VERSION=""
RUN . /tmp/build-env && \
VER="${OPENSHELL_VERSION#v}" && \
if [ -n "$VER" ]; then export OPENSHELL_GIT_VERSION="$VER"; fi && \
RUSTFLAGS="-C target-feature=+crt-static" \
cargo build --release \
--target "${RUST_TARGET}" \
--package openshell-supervisor \
--bin openshell-supervisor \
--no-default-features \
--features defaults-without-telemetry && \
mkdir -p /build/output && \
cp /build/target/${RUST_TARGET}/release/openshell-supervisor /build/output/
cp /build/target/${RUST_TARGET}/release/openshell-supervisor /build/output/ && \
readelf -l /build/output/openshell-supervisor > /tmp/program-headers && \
if ! grep -q 'Requesting program interpreter' /tmp/program-headers; then \
echo "openshell-supervisor is not dynamically linked" >&2; exit 1; \
fi

# ---------------------------------------------------------------------------
# Runtime
Expand All @@ -91,12 +88,11 @@ RUN microdnf install -y --nodocs --setopt=install_weak_deps=0 \
# Enable post-quantum cryptography support in the RHEL system policy.
RUN update-crypto-policies --set DEFAULT:PQ

# Copy the fully-static binary produced by the builder stage.
COPY --from=builder --chmod=0555 /build/output/openshell-supervisor /openshell-supervisor

LABEL com.redhat.component="odh-openshell-supervisor-container" \
description="Statically linked (glibc) sandbox supervisor for OpenShell, run outside the agent workload" \
summary="Statically linked (glibc) sandbox supervisor for OpenShell, run outside the agent workload" \
description="Sandbox supervisor for OpenShell, run outside the agent workload" \
summary="Sandbox supervisor for OpenShell, run outside the agent workload" \
name="rhoai/odh-openshell-supervisor-rhel9" \
maintainer="['managed-open-data-hub@redhat.com']" \
io.openshift.expose-services="" \
Expand Down
7 changes: 1 addition & 6 deletions deploy/konflux/cli/rpms.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ contentOrigin:
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/baseos/os/
- repoid: ubi-9-appstream-rpms
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/appstream/os/
# glibc-static (for `-C target-feature=+crt-static`) ships in CodeReady
# Builder, whose content is public on the UBI CDN.
- repoid: ubi-9-codeready-builder-rpms
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/codeready-builder/os/
packages:
# Build stage: static glibc + build tools
# Build stage: build tools
- gcc
- make
- tar
- xz
- glibc-static
# Build stage: Rust compilation (rustup provides rust/cargo)
- gcc-c++
- cmake
Expand Down
28 changes: 0 additions & 28 deletions deploy/konflux/cli/rpms.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1047,20 +1047,6 @@ arches:
name: zlib
evr: 1.2.11-40.el9
sourcerpm: zlib-1.2.11-40.el9.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/aarch64/codeready-builder/os/Packages/g/glibc-static-2.34-275.el9_8.aarch64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 1249076
checksum: sha256:a683861245c3bbd125301070aca013ed0a7603f6bcf64d99914dcf9ae792b281
name: glibc-static
evr: 2.34-275.el9_8
sourcerpm: glibc-2.34-275.el9_8.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/aarch64/codeready-builder/os/Packages/l/libxcrypt-static-4.4.18-3.el9.aarch64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 111974
checksum: sha256:8bb8a0eb808c389cfec8a0b29ef66a608cc04711b5d4a0ad515f3a32522ae6e0
name: libxcrypt-static
evr: 4.4.18-3.el9
sourcerpm: libxcrypt-4.4.18-3.el9.src.rpm
source: []
module_metadata: []
- arch: x86_64
Expand Down Expand Up @@ -2101,19 +2087,5 @@ arches:
name: zlib
evr: 1.2.11-40.el9
sourcerpm: zlib-1.2.11-40.el9.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/x86_64/codeready-builder/os/Packages/g/glibc-static-2.34-275.el9_8.x86_64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 1532701
checksum: sha256:d35de990a70f4a636753a1e45e2e73b6dd66fc46985bbd6695aaac2c68f399a0
name: glibc-static
evr: 2.34-275.el9_8
sourcerpm: glibc-2.34-275.el9_8.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/x86_64/codeready-builder/os/Packages/l/libxcrypt-static-4.4.18-3.el9.x86_64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 105711
checksum: sha256:e2b914f5e136df3c90367dc222e9d893d0c34662f9f2d496b0cadd7d277c579a
name: libxcrypt-static
evr: 4.4.18-3.el9
sourcerpm: libxcrypt-4.4.18-3.el9.src.rpm
source: []
module_metadata: []
25 changes: 25 additions & 0 deletions deploy/konflux/sandbox/nss-static.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/*
* Static glibc binaries cannot safely load NSS modules from an arbitrary
* workload image. Configure every glibc NSS database before Rust startup so
* lookups use only services built into libc.
*/

extern int __nss_configure_lookup(const char *database, const char *service_line);

static void __attribute__((constructor)) configure_static_nss(void)
{
static const char *const file_databases[] = {
"aliases", "ethers", "group", "gshadow", "initgroups",
"netgroup", "networks", "passwd", "protocols", "publickey",
"rpc", "services", "shadow",
};
unsigned long i;

for (i = 0; i < sizeof(file_databases) / sizeof(file_databases[0]); ++i)
(void)__nss_configure_lookup(file_databases[i], "files");

(void)__nss_configure_lookup("hosts", "files dns");
}
7 changes: 1 addition & 6 deletions deploy/konflux/supervisor/rpms.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ contentOrigin:
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/baseos/os/
- repoid: ubi-9-appstream-rpms
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/appstream/os/
# glibc-static (for `-C target-feature=+crt-static`) ships in CodeReady
# Builder, whose content is public on the UBI CDN.
- repoid: ubi-9-codeready-builder-rpms
baseurl: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/$basearch/codeready-builder/os/
packages:
# Build stage: static glibc + build tools
# Build stage: build tools
- gcc
- make
- tar
- xz
- glibc-static
# Build stage: Rust compilation (rustup provides rust/cargo)
- gcc-c++
- cmake
Expand Down
28 changes: 0 additions & 28 deletions deploy/konflux/supervisor/rpms.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -963,20 +963,6 @@ arches:
name: zlib
evr: 1.2.11-40.el9
sourcerpm: zlib-1.2.11-40.el9.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/aarch64/codeready-builder/os/Packages/g/glibc-static-2.34-275.el9_8.aarch64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 1249076
checksum: sha256:a683861245c3bbd125301070aca013ed0a7603f6bcf64d99914dcf9ae792b281
name: glibc-static
evr: 2.34-275.el9_8
sourcerpm: glibc-2.34-275.el9_8.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/aarch64/codeready-builder/os/Packages/l/libxcrypt-static-4.4.18-3.el9.aarch64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 111974
checksum: sha256:8bb8a0eb808c389cfec8a0b29ef66a608cc04711b5d4a0ad515f3a32522ae6e0
name: libxcrypt-static
evr: 4.4.18-3.el9
sourcerpm: libxcrypt-4.4.18-3.el9.src.rpm
source: []
module_metadata: []
- arch: x86_64
Expand Down Expand Up @@ -1926,19 +1912,5 @@ arches:
name: zlib
evr: 1.2.11-40.el9
sourcerpm: zlib-1.2.11-40.el9.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/x86_64/codeready-builder/os/Packages/g/glibc-static-2.34-275.el9_8.x86_64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 1532701
checksum: sha256:d35de990a70f4a636753a1e45e2e73b6dd66fc46985bbd6695aaac2c68f399a0
name: glibc-static
evr: 2.34-275.el9_8
sourcerpm: glibc-2.34-275.el9_8.src.rpm
- url: https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi9/9/x86_64/codeready-builder/os/Packages/l/libxcrypt-static-4.4.18-3.el9.x86_64.rpm
repoid: ubi-9-codeready-builder-rpms
size: 105711
checksum: sha256:e2b914f5e136df3c90367dc222e9d893d0c34662f9f2d496b0cadd7d277c579a
name: libxcrypt-static
evr: 4.4.18-3.el9
sourcerpm: libxcrypt-4.4.18-3.el9.src.rpm
source: []
module_metadata: []
Loading