# OCI image of the Rust runtime (engine + gateway + API + `leleka`): binaries and CUDA 12 cuBLAS only. # # NOT in the image, by design: # * the model (shards, KAR archive, MTP pack, tokenizer) - mount a volume at /models; never baked, never in Git; # * the NVIDIA driver and libcuda.so.1 - injected by the NVIDIA Container Toolkit (docker run --gpus all); # * secrets - the tokens and the API key are generated into the /state volume on the first start; # * the sealed PTX is embedded in the binaries (sm_120, and the sm_86 companions when built with `sm86`). # # Build context = an unpacked release tarball (it holds bin/ and MANIFEST.json),: # tar -xJf leleka-VERSION-linux-x86_64.tar.xz && cd leleka-VERSION-linux-x86_64 # docker build -f /path/to/deploy/Containerfile.rust-runtime -t leleka-runtime:VERSION . # # Base: Ubuntu 24.04 (glibc 2.39), the oldest glibc the release is built against. Pin the digest for a release: # docker buildx imagetools inspect ubuntu:24.04 -> --build-arg BASE=ubuntu:24.04@sha256:... ARG BASE=ubuntu:24.04 # --- stage 1: the pinned NVIDIA cuBLAS 12.9.1.4 redistributable, checksum-verified by BuildKit --------------- FROM ${BASE} AS cublas ARG CUBLAS_URL=https://developer.download.nvidia.com/compute/cuda/redist/libcublas/linux-x86_64/libcublas-linux-x86_64-12.9.1.4-archive.tar.xz ARG CUBLAS_SHA256=546addc4a9d82b8f23aa9ba9274b6bc0429a63008a31c759884ac24880796057 ADD --checksum=sha256:${CUBLAS_SHA256} ${CUBLAS_URL} /cublas.tar.xz RUN mkdir /out \ && tar -xJf /cublas.tar.xz -C /out --strip-components=1 --wildcards '*/lib/libcublas.so.12*' '*/lib/libcublasLt.so.12*' '*/LICENSE' \ && mv /out/LICENSE /out/lib/LICENSE-cublas.txt # --- stage 2: the runtime --------------------------------------------------------------------------------------- FROM ${BASE} ARG VERSION=dev LABEL org.opencontainers.image.title="leleka-runtime" \ org.opencontainers.image.description="Leleka runtime: Rust CUDA engine, gateway and API. Model volume mounted externally." \ org.opencontainers.image.version="${VERSION}" RUN groupadd --gid 10001 leleka \ && useradd --uid 10001 --gid 10001 --no-create-home --home-dir /state --shell /usr/sbin/nologin leleka \ && install -d -m 0755 /opt/leleka/bin /opt/leleka/lib/cublas /usr/share/leleka \ && install -d -m 0700 -o leleka -g leleka /state \ && install -d -m 0755 -o leleka -g leleka /models COPY --chmod=0755 bin/ /opt/leleka/bin/ COPY --from=cublas --chmod=0644 /out/lib/ /opt/leleka/lib/cublas/ # MANIFEST.json sits next to bin/ so that `leleka` sees the build features (sm86) and the binary digests. COPY --chmod=0644 MANIFEST.json PROVENANCE.json SHA256SUMS /opt/leleka/ COPY --chmod=0755 install.sh /usr/share/leleka/install.sh # `leleka up` finds libcublas.so.12 in PREFIX/lib/cublas on its own and records it in the service environment. # The paths below are the defaults of `leleka` (--prefix / --state-dir / --assets). ENV LELEKA_PREFIX=/opt/leleka \ LELEKA_STATE=/state \ LELEKA_ASSETS=/models \ HOME=/state \ NVIDIA_VISIBLE_DEVICES=all \ NVIDIA_DRIVER_CAPABILITIES=compute,utility USER 10001:10001 WORKDIR /state VOLUME ["/models", "/state"] EXPOSE 8081 # Ready = the API answers /ready with the key kept in /state. The first start downloads, verifies and converts # the model (hours), so the start period is long; a restart with a populated volume is minutes. HEALTHCHECK --interval=30s --timeout=10s --start-period=4h --retries=3 \ CMD ["/opt/leleka/bin/leleka", "status"] # SIGTERM -> `leleka` drains the API, then stops the gateway and the engine. STOPSIGNAL SIGTERM ENTRYPOINT ["/opt/leleka/bin/leleka"] CMD ["up", "--foreground", "--no-install-cublas", "--api-bind", "0.0.0.0", "--timeout-s", "86400"]