|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -FROM golang:1.24.2@sha256:b51b7beeabe2e2d8438ba4295c59d584049873a480ba0e7b56d80db74b3e3a3a AS build |
| 15 | +# Get libc and sources from Ubuntu24, build libhlml, repackage hlml sources with shared lib build modifications |
| 16 | +FROM ubuntu:24.04@sha256:80dd3c3b9c6cecb9f1667e9290b3bc61b78c2678c02cbdae5f0fea92cc6734ab AS ubuntu |
| 17 | +RUN \ |
| 18 | +cat /etc/apt/sources.list.d/ubuntu.sources && \ |
| 19 | +sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources && \ |
| 20 | +apt-get update && \ |
| 21 | +apt-get install -y dpkg-dev cmake build-essential wget bison flex libyaml-dev pkg-config libudev-dev zlib1g-dev && \ |
| 22 | +mkdir /tmp/src && \ |
| 23 | +cd /tmp/src && \ |
| 24 | +apt-get source libc6 coreutils dash && \ |
| 25 | +wget https://vault.habana.ai/artifactory/misc/fw-tools-sources/1.23.0/hl-smi-SA.tgz && \ |
| 26 | +mv hl-smi-SA.tgz hl-smi-SA.tar.gz && mkdir hl-smi-SA && cd hl-smi-SA && \ |
| 27 | +tar -xf ../hl-smi-SA.tar.gz && \ |
| 28 | +make 3rd-party && OPT_C='-O2 -DNDEBUG -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong' && \ |
| 29 | +OPT_CXX='-O2 -DNDEBUG -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong' && \ |
| 30 | +HARDEN_LD='-Wl,-O1,--as-needed,-z,relro,-z,now' && \ |
| 31 | +make -C 3rd-parties/extract/pciutils-3.13.0 clean && \ |
| 32 | +make -C 3rd-parties/extract/pciutils-3.13.0 SHARED=no HWDB=no CFLAGS="$OPT_C" && \ |
| 33 | +make -C 3rd-parties/extract/lm-sensors-3-6-0 clean && \ |
| 34 | +make -C 3rd-parties/extract/lm-sensors-3-6-0 CFLAGS="$OPT_C" BUILD_STATIC_LIB=1 && \ |
| 35 | +cp -f 3rd-parties/extract/pciutils-3.13.0/lib/libpci.a 3rd-parties/extract/prod/libpci.a && \ |
| 36 | +cp -f 3rd-parties/extract/lm-sensors-3-6-0/lib/libsensors.a 3rd-parties/extract/prod/libsensors.a && \ |
| 37 | +cmake -S . -B build-shared -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_FLAGS_RELEASE="$OPT_C" -DCMAKE_CXX_FLAGS_RELEASE="$OPT_CXX" && \ |
| 38 | +cmake --build build-shared --target hlml-raw && \ |
| 39 | +gcc -shared -O2 $HARDEN_LD -Wl,--whole-archive \ |
| 40 | +build-shared/make/hlml/libhlml-raw.a \ |
| 41 | +3rd-parties/extract/prod/libsensors.a \ |
| 42 | +3rd-parties/extract/prod/libeeprom-util.a \ |
| 43 | +3rd-parties/extract/prod/libhl-thunk-static.a \ |
| 44 | +3rd-parties/extract/prod/libhl-thunk-err_injection-static.a \ |
| 45 | +3rd-parties/extract/prod/libpci.a \ |
| 46 | +-Wl,--no-whole-archive -ldl -lm -lz -o libhlml.so |
| 47 | + |
| 48 | +FROM golang:1.25.8@sha256:dfae680962532eeea67ab297f1166c2c4e686edb9a8f05f9d02d96fc9191833e AS build |
| 49 | + |
16 | 50 | ARG LOCAL_LICENSES |
17 | 51 | WORKDIR /build |
18 | 52 | COPY . . |
19 | 53 |
|
| 54 | +# install libhlml.so from deb for licenses |
| 55 | +RUN \ |
| 56 | +curl -fsSL https://vault.habana.ai/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/habanalabs.gpg > /dev/null && \ |
| 57 | +wget -q -O /etc/apt/sources.list.d/habanalabs_synapseai.list "https://vault.habana.ai/artifactory/gaudi-installer/repos/1.23.0/ubuntu24.04/habanalabs_synapseai.list" > /dev/null && \ |
| 58 | +sed -i "s/^deb/deb [trusted=yes]/" /etc/apt/sources.list.d/habanalabs_synapseai.list && \ |
| 59 | +apt-get update && \ |
| 60 | +apt-get download habanalabs-firmware-tools && \ |
| 61 | +dpkg --force-all -i *.deb |
| 62 | + |
| 63 | +# Build Gaudi driver binary, copy original licenses and sources, and put the GPL license to the root of the container image |
20 | 64 | RUN make gaudi && \ |
21 | 65 | mkdir -p /install_root && \ |
22 | 66 | if [ -z "$LOCAL_LICENSES" ]; then \ |
23 | | - make licenses; \ |
| 67 | + make gaudi-licenses; \ |
24 | 68 | fi && \ |
25 | 69 | cp -r licenses /install_root/ && \ |
| 70 | +mkdir /install_root/licenses/habanalabs && \ |
| 71 | +cp /usr/share/doc/habanalabs-firmware-tools/* /install_root/licenses/habanalabs/ && \ |
| 72 | +cp cmd/kubelet-gaudi-plugin/LICENSE /install_root/LICENSE && \ |
26 | 73 | cp bin/kubelet-gaudi-plugin /install_root/ |
27 | 74 |
|
28 | 75 | FROM scratch |
29 | 76 | LABEL description="Intel Gaudi resource driver for Kubernetes" |
30 | 77 |
|
31 | | -COPY --from=build /install_root/ / |
32 | | -CMD ["/kubelet-gaudi-plugin"] |
| 78 | +COPY --from=build /install_root / |
| 79 | +COPY --from=ubuntu /tmp/src/hl-smi-SA/libhlml.so /usr/lib/habanalabs/libhlml.so |
| 80 | +COPY --from=ubuntu /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 |
| 81 | +COPY --from=ubuntu /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 |
| 82 | +COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libm.so.6 /usr/lib/x86_64-linux-gnu/libm.so.6 |
| 83 | +COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so.2 |
| 84 | +COPY --from=ubuntu /usr/lib/x86_64-linux-gnu/libz.so.1 /usr/lib/x86_64-linux-gnu/libz.so.1 |
| 85 | +COPY --from=ubuntu /bin/cat /bin/cat |
| 86 | +COPY --from=ubuntu /bin/sh /bin/sh |
| 87 | +COPY --from=ubuntu /tmp/src/*tar.* /src/ |
| 88 | + |
| 89 | +ENV LD_LIBRARY_PATH=/usr/lib/habanalabs:/lib/x86_64-linux-gnu:/lib64:/usr/lib/x86_64-linux-gnu |
| 90 | +ENV PATH=/bin |
0 commit comments