|
| 1 | +# CLEAR_LINUX_BASE and CLEAR_LINUX_VERSION can be used to make the build |
| 2 | +# reproducible by choosing an image by its hash and installing an OS version |
| 3 | +# with --version=: |
| 4 | +# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4 |
| 5 | +# CLEAR_LINUX_VERSION="--version=29970" |
| 6 | +# |
| 7 | +# This is used on release branches before tagging a stable version. |
| 8 | +# The master branch defaults to using the latest Clear Linux. |
| 9 | +ARG CLEAR_LINUX_BASE=clearlinux/golang:latest |
| 10 | + |
| 11 | +FROM ${CLEAR_LINUX_BASE} as builder |
| 12 | + |
| 13 | +ARG CLEAR_LINUX_VERSION= |
| 14 | + |
| 15 | +RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION} |
| 16 | +RUN mkdir /install_root \ |
| 17 | + && swupd os-install \ |
| 18 | + ${CLEAR_LINUX_VERSION} \ |
| 19 | + --path /install_root \ |
| 20 | + --statedir /swupd-state \ |
| 21 | + --bundles=os-core,rsync \ |
| 22 | + --no-boot-update \ |
| 23 | + && rm -rf /install_root/var/lib/swupd/* |
| 24 | + |
| 25 | +# Build CRI Hook |
| 26 | +ARG DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes |
| 27 | +WORKDIR $DIR |
| 28 | +COPY . . |
| 29 | +RUN cd $DIR/cmd/fpga_crihook && \ |
| 30 | + go install && \ |
| 31 | + chmod a+x /go/bin/fpga_crihook && \ |
| 32 | + cd $DIR/cmd/fpga_tool && \ |
| 33 | + go install && \ |
| 34 | + chmod a+x /go/bin/fpga_tool && \ |
| 35 | + install -D ${DIR}/LICENSE /install_root/usr/local/share/package-licenses/intel-device-plugins-for-kubernetes/LICENSE |
| 36 | + |
| 37 | +# Minimal result image |
| 38 | +FROM scratch as final |
| 39 | +COPY --from=builder /install_root / |
| 40 | + |
| 41 | +ARG SRC_DIR=/usr/local/fpga-sw.src |
| 42 | +ARG DST_DIR=/opt/intel/fpga-sw |
| 43 | + |
| 44 | +# CRI hook |
| 45 | +ARG CRI_HOOK=intel-fpga-crihook |
| 46 | +ARG FPGA_TOOL=fpgatool |
| 47 | +ARG HOOK_CONF=$CRI_HOOK.json |
| 48 | +ARG HOOK_CONF_SRC=$SRC_DIR/$HOOK_CONF |
| 49 | +ARG HOOK_CONF_DST=$DST_DIR/$HOOK_CONF |
| 50 | + |
| 51 | +COPY --from=builder /go/bin/fpga_crihook $SRC_DIR/$CRI_HOOK |
| 52 | +COPY --from=builder /go/bin/fpga_tool $SRC_DIR/$FPGA_TOOL |
| 53 | + |
| 54 | +RUN echo -e "{\n\ |
| 55 | + \"hook\" : \"$DST_DIR/$CRI_HOOK\",\n\ |
| 56 | + \"stage\" : [ \"prestart\" ],\n\ |
| 57 | + \"annotation\": [ \"fpga.intel.com/region\" ]\n\ |
| 58 | +}\n">>$HOOK_CONF_SRC |
| 59 | + |
| 60 | +RUN echo -e "#!/bin/sh\n\ |
| 61 | +rsync -a --delete $SRC_DIR/ $DST_DIR\n\ |
| 62 | +mkdir -p /etc/containers/oci/hooks.d\n\ |
| 63 | +ln -sf $HOOK_CONF_DST /etc/containers/oci/hooks.d/$HOOK_CONF\n\ |
| 64 | +rm $DST_DIR/deploy.sh\n\ |
| 65 | +">> $SRC_DIR/deploy.sh && chmod +x $SRC_DIR/deploy.sh |
| 66 | + |
| 67 | +CMD [ "/opt/intel/fpga-sw.src/deploy.sh" ] |
0 commit comments