Skip to content

Commit

Permalink
BUILD: Fix yum taking for ages on el6 and el7
Browse files Browse the repository at this point in the history
Force ulimit nofile 1024 when building the base rpmbuild el6/el7
images and when running the container to build the RPM.

Yum might take for ages to complete because it CLOEXEC on all available
file descriptors and recent dockers sets a very high default limit.

References:
https://stackoverflow.com/questions/74345206/centos-7-docker-yum-installation-gets-stuck
https://bugzilla.redhat.com/show_bug.cgi?id=1537564
rpm-software-management/rpm#444
  • Loading branch information
julthomas committed Dec 9, 2023
1 parent a4fcbbb commit 59955cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rpmbuild-docker
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,16 @@ echo "OUTPUTDIR: $OUTPUTDIR"
echo "PREBUILDSCRIPT: ${PREBUILDSCRIPT:-none}"
echo "REPO: ${REPO:-none}"

# Yum might take for ages to complete because it CLOEXEC on all available
# file descriptors and recent dockers sets a very high default limit.
# https://bugzilla.redhat.com/show_bug.cgi?id=1537564
# https://github.com/rpm-software-management/rpm/pull/444
DOCKER_OPTS_DIST_el6=( --ulimit 'nofile=1024' )
function dockerfile_for_dist_el6() {
cat <<'EOF'
FROM centos:6
RUN set -x && \
ulimit -n 1024 && \
sed -i -re 's,mirror\.centos\.org,vault.centos.org,; s,^(mirrorlist),#\1,; s,^#(baseurl),\1,' /etc/yum.repos.d/CentOS-*.repo && \
yum update -y && \
yum install -y createrepo gcc make rpm-build && \
Expand All @@ -182,10 +188,16 @@ RUN set -x && \
EOF
}

# Yum might take for ages to complete because it CLOEXEC on all available
# file descriptors and recent dockers sets a very high default limit.
# https://bugzilla.redhat.com/show_bug.cgi?id=1537564
# https://github.com/rpm-software-management/rpm/pull/444
DOCKER_OPTS_DIST_el7=( --ulimit 'nofile=1024' )
function dockerfile_for_dist_el7() {
cat <<'EOF'
FROM centos:7
RUN set -x && \
ulimit -n 1024 && \
yum update -y && \
yum install -y createrepo gcc make rpm-build && \
echo '* - nproc 2048' >> /etc/security/limits.d/90-nproc.conf && \
Expand Down

0 comments on commit 59955cf

Please sign in to comment.