intel-device-plugins-for-ku.../build/docker/intel-fpga-initcontainer.Dockerfile
Ed Bartosh a4c124777a fpga: fix deployment setup
- used ENTRYPOINT instead of CMD in plugin and admission webhook
  Dockerfiles to avoid duplicating commands in the pod yamls
- fixed path to deploy.sh script in fpga initcontainer Dockerfile
2019-08-27 11:03:03 +03:00

68 lines
2.1 KiB
Docker

# CLEAR_LINUX_BASE and CLEAR_LINUX_VERSION can be used to make the build
# reproducible by choosing an image by its hash and installing an OS version
# with --version=:
# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4
# CLEAR_LINUX_VERSION="--version=29970"
#
# This is used on release branches before tagging a stable version.
# The master branch defaults to using the latest Clear Linux.
ARG CLEAR_LINUX_BASE=clearlinux/golang:latest
FROM ${CLEAR_LINUX_BASE} as builder
ARG CLEAR_LINUX_VERSION=
RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION}
RUN mkdir /install_root \
&& 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 $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=/usr/local/fpga-sw
ARG DST_DIR=/opt/intel/fpga-sw
# CRI hook
ARG CRI_HOOK=intel-fpga-crihook
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 $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\
mkdir -p /etc/containers/oci/hooks.d\n\
ln -sf $HOOK_CONF_DST /etc/containers/oci/hooks.d/$HOOK_CONF\n\
rm $DST_DIR/deploy.sh\n\
">> $SRC_DIR/deploy.sh && chmod +x $SRC_DIR/deploy.sh
ENTRYPOINT [ "/usr/local/fpga-sw/deploy.sh" ]