Files
diskless-workstation/serving/spdk/Dockerfile
T
2026-06-14 07:32:06 +00:00

49 lines
2.2 KiB
Docker

# Build SPDK's nvmf_tgt from source.
#
# There is no reliable official `spdk/spdk` image to pull (SPDK's guidance is to
# build your own — https://spdk.io/doc/containers.html), so we compile a pinned
# release here. Single-stage: the image is large and the FIRST build is slow
# (~10-20 min — it pulls submodules incl. DPDK and compiles them), but it's
# self-contained, reproducible, and cached thereafter. Bump SPDK_VERSION to a
# tag from https://github.com/spdk/spdk/releases.
FROM ubuntu:24.04
ARG SPDK_VERSION=v24.09
ARG SPDK_REPO=https://github.com/spdk/spdk
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Shallow-clone the pinned release; submodules at their pinned commits.
RUN git clone --branch "${SPDK_VERSION}" --depth 1 "${SPDK_REPO}" /spdk \
&& git -C /spdk submodule update --init --recursive
# SPDK's own dependency installer (kernel headers, build tools, DPDK deps,
# python for rpc.py, …). Then configure (TCP nvmf transport is in the default
# build; trim the test artifacts) and build.
# apt-get update first: the index was cleared above, and pkgdep.sh runs
# `apt-get install` without refreshing it (else "Unable to locate package …").
#
# pkgdep.sh on Ubuntu 24.04 installs meson/pyelftools into a Python venv (PEP 668),
# so they aren't on PATH where DPDK's make invokes bare `meson`/`ninja`. Install
# the DPDK build tools globally too (meson, ninja-build, python3-pyelftools).
RUN apt-get update \
&& /spdk/scripts/pkgdep.sh \
&& apt-get install -y --no-install-recommends meson ninja-build python3-pyelftools \
&& cd /spdk \
&& ./configure --disable-tests --disable-unit-tests --target-arch=x86-64-v2 \
&& make -j"$(nproc)" \
&& rm -rf /var/lib/apt/lists/*
# nvmf_tgt lives in build/bin; rpc.py in scripts/ (kept ON PATH so its relative
# imports resolve from the source tree). spdk-setup.sh locates both via `command
# -v`. LD_LIBRARY_PATH is defensive in case of a shared-lib build.
ENV PATH=/spdk/build/bin:/spdk/scripts:$PATH \
LD_LIBRARY_PATH=/spdk/build/lib:/spdk/dpdk/build/lib
# spdk-setup.sh is bind-mounted at /spdk-setup.sh and set as the entrypoint by
# docker-compose.yml.