Cleanup and fixes for FPGA initcontainer

- Simplify initcontainer, we don't need OPAE anymore
- Remove old initcontainer related files
This commit is contained in:
Alexander Kanevskiy 2019-08-23 17:33:25 +03:00
parent 71bb38f496
commit 6fd729f12c
3 changed files with 23 additions and 156 deletions

View File

@ -11,70 +11,51 @@ ARG CLEAR_LINUX_BASE=clearlinux/golang:latest
FROM ${CLEAR_LINUX_BASE} as builder
ARG CLEAR_LINUX_VERSION=
ARG OPAE_RElEASE=1.3.2-1
RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION}
# Fetch dependencies and source code
RUN swupd bundle-add wget c-basic devpkg-json-c devpkg-util-linux devpkg-hwloc doxygen Sphinx && \
mkdir -p /usr/src/opae && \
cd /usr/src/opae && \
wget https://github.com/OPAE/opae-sdk/archive/${OPAE_RElEASE}.tar.gz && \
tar xf *.tar.gz
# Build OPAE
RUN cd /usr/src/opae/opae-sdk-${OPAE_RElEASE} && \
mkdir build && \
cd build && \
cmake .. -DBUILD_ASE=0 -DCMAKE_SKIP_BUILD_RPATH=1 -DCMAKE_INSTALL_PREFIX=/opt/intel/fpga-sw/opae && \
make xfpga board_rc fpgaconf fpgainfo
# Install clean os-core and rsync bundle in target directory
RUN mkdir /install_root \
&& swupd os-install ${CLEAR_LINUX_VERSION} \
--path /install_root --statedir /swupd-state \
--bundles=os-core,rsync --no-boot-update \
&& swupd os-install \
${CLEAR_LINUX_VERSION} \
--path /install_root \
--statedir /swupd-state \
--bundles=os-core,rsync \
--no-boot-update \
&& rm -rf /install_root/var/lib/swupd/*
# Build CRI Hook
ARG DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes
WORKDIR $DIR
COPY . .
RUN cd cmd/fpga_crihook && go install && chmod a+x /go/bin/fpga_crihook
RUN cd $DIR/cmd/fpga_crihook && \
go install && \
chmod a+x /go/bin/fpga_crihook && \
cd $DIR/cmd/fpga_tool && \
go install && \
chmod a+x /go/bin/fpga_tool && \
install -D ${DIR}/LICENSE /install_root/usr/local/share/package-licenses/intel-device-plugins-for-kubernetes/LICENSE
# Minimal result image
FROM scratch as final
COPY --from=builder /install_root /
ARG SRC_DIR=/opt/intel/fpga-sw.src
ARG SRC_DIR=/usr/local/fpga-sw.src
ARG DST_DIR=/opt/intel/fpga-sw
# OPAE
# fpgaconf and fpgainfo
COPY --from=builder /usr/src/opae/opae-sdk-*/build/bin/fpga* $SRC_DIR/opae/bin/
# libxfpga.so, libboard_rc.so, libopae-c.so*, libbitstream.so*
COPY --from=builder /usr/src/opae/opae-sdk-*/build/lib/lib*.so* $SRC_DIR/opae/lib/
COPY --from=builder /usr/lib64/libjson-c.so* $SRC_DIR/opae/lib/
COPY --from=builder /usr/lib64/libuuid.so* $SRC_DIR/opae/lib/
RUN echo -e "#!/bin/sh\n\
export LD_LIBRARY_PATH=$DST_DIR/opae/lib\n\
$DST_DIR/opae/bin/fpgaconf \"\$@\"">> $SRC_DIR/opae/fpgaconf-wrapper && \
echo -e "#!/bin/sh\n\
export LD_LIBRARY_PATH=$DST_DIR/opae/lib\n\
$DST_DIR/opae/bin/fpgainfo \"\$@\"">> $SRC_DIR/opae/fpgainfo-wrapper && \
chmod +x $SRC_DIR/opae/*-wrapper
# CRI hook
ARG CRI_HOOK=intel-fpga-crihook
ARG CRI_HOOK_SRC=$SRC_DIR/$CRI_HOOK
ARG CRI_HOOK_DST=$DST_DIR/$CRI_HOOK
ARG FPGA_TOOL=fpgatool
ARG HOOK_CONF=$CRI_HOOK.json
ARG HOOK_CONF_SRC=$SRC_DIR/$HOOK_CONF
ARG HOOK_CONF_DST=$DST_DIR/$HOOK_CONF
COPY --from=builder /go/bin/fpga_crihook $CRI_HOOK_SRC
COPY --from=builder /go/bin/fpga_crihook $SRC_DIR/$CRI_HOOK
COPY --from=builder /go/bin/fpga_tool $SRC_DIR/$FPGA_TOOL
RUN echo -e "{\n\
\"hook\" : \"$DST_DIR/$CRI_HOOK\",\n\
\"stage\" : [ \"prestart\" ],\n\
\"annotation\": [ \"fpga.intel.com/region\" ]\n\
}\n">>$HOOK_CONF_SRC
RUN echo -e "#!/bin/sh\n\
rsync -a --delete $SRC_DIR/ $DST_DIR\n\

View File

@ -1,32 +0,0 @@
#!/bin/sh -e
BUILDER=$1
# check if DCP tarball is present
DCP_TARBALL=a10_gx_pac_ias_1_2_pv_rte_installer.tar.gz
if [ ! -f ${DCP_TARBALL} ] ; then
echo "ERROR: 'Acceleration Stack for Runtime' tarball $DCP_TARBALL not present"
echo "ERROR: Please, download it from https://www.intel.com/content/www/us/en/programmable/solutions/acceleration-hub/downloads.html and run this script again"
exit 1
fi
# build CRI hook
HOOK=fpga_crihook
make -C ../../ $HOOK
cp ../../cmd/$HOOK/$HOOK ./intel-fpga-crihook
# build initcontainer image
WORKSPACE=`realpath .`
IMG="intel-fpga-initcontainer"
TAG=$(git rev-parse HEAD)
if [ -z "${BUILDER}" -o "${BUILDER}" = 'docker' ] ; then
docker build --rm -t $IMG:devel -f $WORKSPACE/$IMG.Dockerfile $WORKSPACE
docker tag $IMG:devel $IMG:$TAG
elif [ "${BUILDER}" = 'buildah' ] ; then
buildah bud -t $IMG:devel -f $WORKSPACE/$IMG.Dockerfile --layers $WORKSPACE
buildah tag $IMG:devel $IMG:$TAG
else
(>&2 echo "Unknown builder ${BUILDER}")
exit 1
fi

View File

@ -1,82 +0,0 @@
### 1. Temporary image to prepare AOCL and OPAE components
FROM centos:centos7.6.1810 as temporary
# install aocl and opae deps
RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
RUN yum -y install which perl uuid libuuid-devel json-c rsync
ADD a10_gx_pac_ias_1_2_pv_rte_installer.tar.gz $WORKDIR
# install opae
RUN tar -zxf a10_gx_pac_ias_1_2_pv_rte_installer/components/a10_gx_pac_ias_1_2_pv.tar.gz sw
# RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# RUN yum -y install hwloc-libs
# --nodeps workarround just for libhwloc.so.5 dependency by fpga_dma_test in opae-tools-extra-1.1.2-1.x86_64
RUN rpm -ihv --nodeps sw/opae-libs*.rpm sw/opae-tools*.rpm sw/opae-devel*.rpm
# install aocl rte
RUN a10_gx_pac_ias_1_2_pv_rte_installer/components/aocl-pro-rte-17.1.1.273-linux.run --mode unattended --installdir / --accept_eula 1
# unpack opencl_bsp
RUN tar -zxf a10_gx_pac_ias_1_2_pv_rte_installer/components/a10_gx_pac_ias_1_2_pv.tar.gz opencl/opencl_bsp.tar.gz
RUN tar -zxf opencl/opencl_bsp.tar.gz && rm -rf opencl_bsp/hardware
### 2. Final initcontainer image
FROM clearlinux:base as final
ARG SRC_DIR=/opt/intel/fpga-sw.src
ARG DST_DIR=/opt/intel/fpga-sw
# OpenCL
COPY --from=temporary aclrte-linux64 $SRC_DIR/opencl/aclrte-linux64
COPY --from=temporary opencl_bsp $SRC_DIR/opencl/opencl_bsp
RUN echo -e "#!/bin/sh\n\
export INTEL_FPGA_ROOT=$DST_DIR\n\
export FPGA_OPENCL_ROOT=\$INTEL_FPGA_ROOT/opencl\n\
export AOCL_BOARD_PACKAGE_ROOT=\$FPGA_OPENCL_ROOT/opencl_bsp\n\
export INTELFPGAOCLSDKROOT=\$FPGA_OPENCL_ROOT/aclrte-linux64\n\
export LD_LIBRARY_PATH=\$AOCL_BOARD_PACKAGE_ROOT/linux64/lib:\$INTEL_FPGA_ROOT/opae/lib\n\
\$INTELFPGAOCLSDKROOT/bin/aocl \"\$@\"" >> $SRC_DIR/opencl/aocl-wrapper
RUN chmod +x $SRC_DIR/opencl/aocl-wrapper
# OPAE
COPY --from=temporary /usr/bin/fpgaconf $SRC_DIR/opae/bin/
COPY --from=temporary /usr/bin/packager $SRC_DIR/opae/bin/
COPY --from=temporary /usr/lib64/libopae-c.so* $SRC_DIR/opae/lib/
COPY --from=temporary /usr/lib64/libjson-c.so* $SRC_DIR/opae/lib/
COPY --from=temporary /usr/lib64/libuuid.so* $SRC_DIR/opae/lib/
RUN echo -e "#!/bin/sh\n\
export LD_LIBRARY_PATH=$DST_DIR/opae/lib\n\
$DST_DIR/opae/bin/fpgaconf \"\$@\"">> $SRC_DIR/opae/fpgaconf-wrapper
RUN chmod +x $SRC_DIR/opae/fpgaconf-wrapper
# CRI hook
ARG CRI_HOOK=intel-fpga-crihook
ARG CRI_HOOK_SRC=$SRC_DIR/$CRI_HOOK
ARG CRI_HOOK_DST=$DST_DIR/$CRI_HOOK
ARG HOOK_CONF=$CRI_HOOK.json
ARG HOOK_CONF_SRC=$SRC_DIR/$HOOK_CONF
ARG HOOK_CONF_DST=$DST_DIR/$HOOK_CONF
COPY ./$CRI_HOOK $CRI_HOOK_SRC
RUN echo -e "{\n\
\"hook\" : \"$CRI_HOOK_DST\",\n\
\"stage\" : [ \"prestart\" ],\n\
\"annotation\": [ \"fpga.intel.com/region\" ]\n\
}\n">>$HOOK_CONF_SRC
# Setup
COPY --from=temporary /usr/bin/rsync /usr/bin/rsync
RUN echo -e "#!/bin/sh\n\
rsync -a --delete $SRC_DIR/ $DST_DIR\n\
ln -sf $HOOK_CONF_DST /etc/containers/oci/hooks.d/$HOOK_CONF\n\
rm $DST_DIR/deploy.sh\n\
">> $SRC_DIR/deploy.sh
RUN chmod +x $SRC_DIR/deploy.sh