diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 00000000000..cece359e13a --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,32 @@ +ARG DISTRO + +FROM scratch as bootstrap +ARG CEPH_CTR_SRC=/usr/local/src/ceph +COPY \ + src/script/lib-build.sh \ + src/script/run-make.sh \ + ${CEPH_CTR_SRC}/src/script/ +COPY debian ${CEPH_CTR_SRC}/debian +COPY \ + ceph.spec.in \ + do_cmake.sh \ + install-deps.sh \ + run-make-check.sh \ + src/script/buildcontainer-setup.sh \ + ${CEPH_CTR_SRC} + + +FROM $DISTRO +ENV FOR_MAKE_CHECK=1 +ARG DISTRO +ARG CEPH_CTR_SRC=/usr/local/src/ceph +ARG CLEAN_DNF=yes +ARG CEPH_BRANCH=main +COPY --from=bootstrap ${CEPH_CTR_SRC} ${CEPH_CTR_SRC} +# Note that we do not use ENV for the following. This is because we do not +# want them permamently stored in the container's layer. +RUN DISTRO=$DISTRO \ + CEPH_BRANCH=$CEPH_BRANCH \ + CLEAN_DNF=$CLEAN_DNF \ + CEPH_CTR_SRC=${CEPH_CTR_SRC} \ + bash -x ${CEPH_CTR_SRC}/buildcontainer-setup.sh diff --git a/src/script/buildcontainer-setup.sh b/src/script/buildcontainer-setup.sh new file mode 100644 index 00000000000..82ca11e88ed --- /dev/null +++ b/src/script/buildcontainer-setup.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +install_container_deps() { + source ./src/script/run-make.sh + prepare +} + +dnf_clean() { + if [ "${CLEAN_DNF}" != no ]; then + dnf clean all + rm -rf /var/cache/dnf/* + fi +} + +set -e +export LOCALE=C +cd ${CEPH_CTR_SRC} + +# If DISTRO_KIND is not already set, derive it from the container's os-release. +if [ -z "$DISTRO_KIND" ]; then + . /etc/os-release + DISTRO_KIND="${ID}:${VERSION_ID}" +fi + +# Execute a container setup process, installing the packges needed to build +# ceph for the given ~ pair. Some distros need extra +# tools in the container image vs. vm hosts or extra tools needed to build +# packages etc. +case "${CEPH_BRANCH}~${DISTRO_KIND}" in + *~*centos*8) + dnf install -y java-1.8.0-openjdk-headless /usr/bin/rpmbuild wget + install_container_deps + dnf_clean + ;; + *~*centos*9|*~*centos*10*|*~fedora*) + dnf install -y /usr/bin/rpmbuild wget + install_container_deps + dnf_clean + ;; + *~*ubuntu*) + apt-get update + apt-get install -y wget reprepro + install_container_deps + ;; + *) + echo "Unknown action, branch or build: ${CEPH_BRANCH}~${DISTRO_KIND}" >&2 + exit 2 + ;; +esac