From 602a900006126a40672dc9a40170d7382901fd20 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Tue, 23 Aug 2022 13:58:36 +0200 Subject: [PATCH] docker: remove pre-install script Remove "pre-install" script used for building "build_base" image and move it's content into Dockerfile. This results in resulting more build layers, but makes rebuilding easier. We can now rebuild or update the image starting at some later cached layer instead of starting pre-install from scratch every time. Change-Id: I78b46cda4bb815ac8cf72c8251a3cc585b373acc Signed-off-by: Karol Latecki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14158 Tested-by: SPDK CI Jenkins Reviewed-by: Boris Glimcher Reviewed-by: Jim Harris Reviewed-by: Pawel Piatek Reviewed-by: Michal Berger Reviewed-by: Tomasz Zawadzki --- docker/build_base/Dockerfile | 30 +++++++++++++++++++++-- docker/build_base/pre-install | 45 ----------------------------------- 2 files changed, 28 insertions(+), 47 deletions(-) delete mode 100755 docker/build_base/pre-install diff --git a/docker/build_base/Dockerfile b/docker/build_base/Dockerfile index 0744ac559..5ff3ca700 100644 --- a/docker/build_base/Dockerfile +++ b/docker/build_base/Dockerfile @@ -3,6 +3,9 @@ FROM fedora:35 AS base +ARG spdk_repo=/tmp/spdk_repo +ARG spdk_tar=/spdk.tar.gz + # Generic args ARG PROXY ARG NO_PROXY @@ -12,8 +15,31 @@ ENV https_proxy=$PROXY ENV no_proxy=$NO_PROXY COPY --chown=root:root spdk.tar.gz /spdk.tar.gz -COPY pre-install /install -RUN /install +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/x86_64/"*.rpm /tmp +RUN mv "/usr/src/fio/fio" /tmp + +# Clean things up +RUN rm -f "$HOME/rpmbuild/rpm/x86_64/"*.rpm +RUN rm -f "$spdk_tar" +RUN rm -rf "$spdk_repo" +RUN dnf clean all # We are doing a multi-stage build here. This means that previous image, # base, is going to end up as an intermediate one, untagged, - this diff --git a/docker/build_base/pre-install b/docker/build_base/pre-install deleted file mode 100755 index 240d34c9e..000000000 --- a/docker/build_base/pre-install +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -e - -spdk_repo=$(mktemp -dt "spdk.XXXXXX") -spdk_tar=/spdk.tar.gz - -cleanup() { - - rm -f "$HOME/rpmbuild/rpm/x86_64/"*.rpm - rm -f "$spdk_tar" - rm -rf "$spdk_repo" -} - -trap 'cleanup' EXIT - -if [[ ! -e $spdk_tar ]]; then - printf 'Missing %s\n' "$spdk_tar" >&2 - exit 1 -fi - -tar -C "$spdk_repo" -xf "$spdk_tar" -chown -R root:root "$spdk_repo" - -# Required for building RPM -dnf install -y rpm-build - -# Spice it a bit with supported sources -"$spdk_repo/scripts/pkgdep.sh" -d -"$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. -"$spdk_repo/configure" > /dev/null - -# Deploy SPDK inside the container -DEPS="no" "$spdk_repo/rpmbuild/rpm.sh" \ - --with-shared \ - --with-virtio \ - --with-fio - -mv "$HOME/rpmbuild/rpm/x86_64/"*.rpm /tmp -mv "/usr/src/fio/fio" /tmp -dnf clean all