Spdk/docker/build_base/Dockerfile

67 lines
1.8 KiB
Docker
Raw Normal View History

docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2021 Intel Corporation
#
docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
FROM fedora:35 AS base
docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
ARG spdk_repo=/tmp/spdk_repo
ARG spdk_tar=/spdk.tar.gz
docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
# Generic args
ARG PROXY
ARG NO_PROXY
ENV http_proxy=$PROXY
ENV https_proxy=$PROXY
ENV no_proxy=$NO_PROXY
COPY --chown=root:root spdk.tar.gz /spdk.tar.gz
RUN if [[ ! -e $spdk_tar ]]; then printf 'Missing %s\n' "$spdk_tar" >&2; exit 1; fi
RUN mkdir -p "$spdk_repo" && \
tar -C "$spdk_repo" -xf "$spdk_tar" && \
chown -R root:root "$spdk_repo"
RUN dnf install -y rpm-build
RUN "$spdk_repo/scripts/pkgdep.sh" -d
RUN "$spdk_repo/test/common/config/vm_setup.sh" --test-conf=fio
# HACK: In case we received a .tar with built SPDK we need to overwrite the
# configuration to update all the paths make would need to lookup - this is
# needed since we execute inside a different mount namespace so we won't be
# able to find any absolute paths that were used prior creating the .tar.
RUN "$spdk_repo/configure"
RUN DEPS="no" "$spdk_repo/rpmbuild/rpm.sh" \
--with-shared \
--with-virtio \
--with-fio
RUN mv "$HOME/rpmbuild/rpm/$(uname -m)/"*.rpm /tmp
RUN mv "/usr/src/fio/fio" /tmp
# Clean things up
RUN rm -f "$HOME/rpmbuild/rpm/$(uname -m)/"*.rpm
RUN rm -f "$spdk_tar"
RUN rm -rf "$spdk_repo"
RUN dnf clean all
docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
# We are doing a multi-stage build here. This means that previous image,
# base, is going to end up as an intermediate one, untagged, <none> - this
# image can be then manually removed (--force-rm doesn't work here. Go
# figure).
FROM fedora:35 AS spdk
docker: Add docker-compose for building basic SPDK containers This suite can be used to deploy containers with the following functionality (more details in README.md): - storage-target - proxy-container - traffic-generator This will run simple fio test as per fio.conf against nvmf controller provided by initiator-container. Similar task can be performed directly from initiator-container as well. Each container includes SPDK installation with most common tools, e.g. rpc.py, available under $PATH. This allows for something like: docker-compose exec storage-target rpc.py nvmf_get_subsystems Note that SPDK environment heavily depends on a running kernel hence all the containers need to be privileged. That said, to make sure containers are not affecting the host too much, some tasks must be done prior running them. This includes: - loading proper kernel modules (like nvme-fabrics, etc.) - allocating hugepages and having at least one hugetlbfs mount available under /dev/hugepages base_build is created as docker multi-stage build. This is done in order to decrease the size of the final image. The SPDK RPMs are built inside a base image and then copied over to the main image (+ fio binary) - this leaves all the dependencies inside the intermediate image instead of the final one. The resulted difference in size may look similar to the following (it may differ depending on the docker version etc.): no multi-stage build: spdk_base == 1.04GB multi-stage build: spdk_base == 261MB Signed-off-by: Michal Berger <michalx.berger@intel.com> Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I825bd0d0bb4071bd9d44b6a0749c033894899ae0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9055 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Monica Kenguva <monica.kenguva@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
2021-08-03 07:16:49 +00:00
LABEL maintainer=spdk.io
# Proxy configuration must be set for each build separately...
ARG PROXY
ARG NO_PROXY
ENV http_proxy=$PROXY
ENV https_proxy=$PROXY
ENV no_proxy=$NO_PROXY
# Copy SPDK's RPMs built during pre-install step.
COPY --from=base /tmp/*.rpm /tmp/
COPY --from=base /tmp/fio /tmp/
# Wrap up the image
COPY post-install /install
RUN /install