|
8 | 8 | # build of main. For dev the sandbox and supervisor images are built here |
9 | 9 | # too (--target sandbox / supervisor), as the official images of main are |
10 | 10 | # not tagged. |
| 11 | +# |
| 12 | +# OPENSHELL_PATCH picks the supervisor: release (the release's binary), or |
| 13 | +# h2-l7 (v0.1.5's source with h2-l7.patch, which adds HTTP/2 for opted-in |
| 14 | +# endpoints, built here with Rust; only for v0.1.5). The gateway image |
| 15 | +# carries the same supervisor at /openshell-supervisor, so it serves as the |
| 16 | +# sandboxes' supervisor image too (gateway.PatchedSupervisor). |
11 | 17 | ARG OPENSHELL_TAG=v0.1.5 |
| 18 | +ARG OPENSHELL_PATCH=h2-l7 |
12 | 19 |
|
13 | 20 | FROM ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac AS base |
14 | 21 | RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl socat openssh-client \ |
@@ -48,18 +55,60 @@ RUN set -e; base=https://github.com/NVIDIA/OpenShell/releases/download/${OPENSHE |
48 | 55 | tar xzf "$f.tar.gz" -C /out; done; \ |
49 | 56 | cd /; rm -rf /dl; /out/openshell-gateway --version; /out/openshell --version |
50 | 57 |
|
| 58 | +FROM fetch AS supervisor-release |
| 59 | + |
| 60 | +# v0.1.5's source (the tag's commit) with the patch applied, built as the |
| 61 | +# release builds openshell-supervisor (crates' version set to the release's, |
| 62 | +# default features, glibc) with the repository's toolchain, 1.95.0. rustup-init |
| 63 | +# is pinned by SHA-256 per architecture; rustup checks the toolchain itself. |
| 64 | +FROM base AS supervisor-h2-l7 |
| 65 | +ARG OPENSHELL_TAG |
| 66 | +RUN apt-get update && apt-get install -y --no-install-recommends git build-essential clang cmake pkg-config \ |
| 67 | + && rm -rf /var/lib/apt/lists/* |
| 68 | +RUN set -e; [ "$OPENSHELL_TAG" = v0.1.5 ] || { echo "h2-l7.patch is for OpenShell v0.1.5, not $OPENSHELL_TAG" >&2; exit 1; }; \ |
| 69 | + a=$(uname -m); case "$a" in \ |
| 70 | + x86_64) want=dda7234360b7f578ca8b0ddcb80145646fa61a67c1720a5abc7051b35c9fcb71 ;; \ |
| 71 | + aarch64) want=15f6e4ce9f583b929c996c91562bad6d4454f3281de858b02cdfdef615fac433 ;; \ |
| 72 | + *) echo "unsupported architecture $a" >&2; exit 1 ;; \ |
| 73 | + esac; \ |
| 74 | + curl -fsSL -o /tmp/rustup-init "https://static.rust-lang.org/rustup/archive/1.29.1/$a-unknown-linux-gnu/rustup-init"; \ |
| 75 | + echo "$want /tmp/rustup-init" | sha256sum --check --strict -; \ |
| 76 | + chmod +x /tmp/rustup-init; /tmp/rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.95.0; rm /tmp/rustup-init |
| 77 | +ENV PATH=/root/.cargo/bin:$PATH RUSTUP_TOOLCHAIN=1.95.0 |
| 78 | +WORKDIR /src |
| 79 | +# The version is set in Cargo.lock too (only the workspace's crates are at |
| 80 | +# 0.0.0), so --locked holds. |
| 81 | +RUN git init -q . && git fetch -q --depth 1 https://github.com/NVIDIA/OpenShell.git bdb956f2cd65a635f1294fccf1d138d263bf650f \ |
| 82 | + && git checkout -q FETCH_HEAD \ |
| 83 | + && sed -i 's/^version = "0\.0\.0"$/version = "0.1.5"/' Cargo.toml Cargo.lock \ |
| 84 | + && cargo fetch --locked |
| 85 | +# The unpatched build, in a layer the patch does not invalidate: a change to |
| 86 | +# the patch rebuilds only the crates it touches and those depending on them. |
| 87 | +RUN cargo build --release --locked --offline -p openshell-supervisor --bin openshell-supervisor |
| 88 | +COPY h2-l7.patch /tmp/ |
| 89 | +# OPENSHELL_HTTP2_ENDPOINTS: the destinations offered HTTP/2, iwato-modal's |
| 90 | +# endpoints (TestHTTP2EndpointsAreModals). |
| 91 | +RUN git apply /tmp/h2-l7.patch \ |
| 92 | + && OPENSHELL_HTTP2_ENDPOINTS=api.modal.com:443,api.modal2.com:443 \ |
| 93 | + cargo build --release --locked --offline -p openshell-supervisor --bin openshell-supervisor \ |
| 94 | + && mkdir /out && cp target/release/openshell-supervisor /out/ \ |
| 95 | + && rm -rf target && /out/openshell-supervisor --version |
| 96 | + |
| 97 | +FROM supervisor-${OPENSHELL_PATCH} AS supervisor-bin |
| 98 | + |
51 | 99 | # As deploy/docker/Dockerfile.sandbox and Dockerfile.supervisor upstream. |
52 | 100 | FROM scratch AS sandbox |
53 | 101 | COPY --from=fetch --chmod=0555 /out/openshell-sandbox /openshell-sandbox |
54 | 102 | USER 65532:65532 |
55 | 103 | ENTRYPOINT ["/openshell-sandbox"] |
56 | 104 |
|
57 | 105 | FROM ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac AS supervisor |
58 | | -COPY --from=fetch --chmod=0555 /out/openshell-supervisor /openshell-supervisor |
| 106 | +COPY --from=supervisor-bin --chmod=0555 /out/openshell-supervisor /openshell-supervisor |
59 | 107 | ENTRYPOINT ["/openshell-supervisor"] |
60 | 108 |
|
61 | 109 | FROM base AS gateway |
62 | 110 | COPY --from=fetch /out/openshell-gateway /out/openshell /usr/local/bin/ |
| 111 | +COPY --from=supervisor-bin --chmod=0555 /out/openshell-supervisor /openshell-supervisor |
63 | 112 | COPY gateway.toml gateway-docker.toml entrypoint.sh /etc/openshell/ |
64 | 113 | RUN chmod 0755 /etc/openshell/entrypoint.sh |
65 | 114 | # The CLI inside this container (wslc container exec ... openshell ...) |
|
0 commit comments