Random error creates a Docker image of `NGINX` with the `subs_filter`

I have this Dockerfile which creates a Docker image of NGINX with the subs_filter module enabled.:

ARG NGINX_FROM_IMAGE=nginx:mainline

FROM --platform=linux/amd64 ${NGINX_FROM_IMAGE} as builder

ARG ENABLED_MODULES

SHELL ["/bin/bash", "-exo", "pipefail", "-c"]

RUN if [ "$ENABLED_MODULES" = "" ]; then 
        echo "No additional modules enabled, exiting"; 
        exit 1; 
    fi

    
COPY ./ /modules/

RUN apt-get clean && apt-get update 
    && apt-get install -y --no-install-suggests --no-install-recommends 
                patch make wget mercurial devscripts debhelper dpkg-dev 
                quilt lsb-release build-essential libxml2-utils xsltproc 
                equivs git g++ libparse-recdescent-perl 
    && XSLSCRIPT_SHA512="f7194c5198daeab9b3b0c3aebf006922c7df1d345d454bd8474489ff2eb6b4bf8e2ffe442489a45d1aab80da6ecebe0097759a1e12cc26b5f0613d05b7c09ffa *stdin" 
    && wget -O /tmp/xslscript.pl https://hg.nginx.org/xslscript/raw-file/01dc9ba12e1b/xslscript.pl 
    && if [ "$(cat /tmp/xslscript.pl | openssl sha512 -r)" = "$XSLSCRIPT_SHA512" ]; then 
        echo "XSLScript checksum verification succeeded!"; 
        chmod +x /tmp/xslscript.pl; 
        mv /tmp/xslscript.pl /usr/local/bin/; 
    else 
        echo "XSLScript checksum verification failed!"; 
        exit 1; 
    fi 
    && hg clone -r ${NGINX_VERSION}-${PKG_RELEASE%%~*} https://hg.nginx.org/pkg-oss/ 
    && cd pkg-oss 
    && mkdir /tmp/packages 
    && for module in $ENABLED_MODULES; do 
        echo "Building $module for nginx-$NGINX_VERSION"; 
        if [ -d /modules/$module ]; then 
            echo "Building $module from user-supplied sources"; 
            # check if module sources file is there and not empty
            if [ ! -s /modules/$module/source ]; then 
                echo "No source file for $module in modules/$module/source, exiting"; 
                exit 1; 
            fi; 
            # some modules require build dependencies
            if [ -f /modules/$module/build-deps ]; then 
                echo "Installing $module build dependencies"; 
                apt-get update && apt-get install -y --no-install-suggests --no-install-recommends $(cat /modules/$module/build-deps | xargs); 
            fi; 
            # if a module has a build dependency that is not in a distro, provide a
            # shell script to fetch/build/install those
            # note that shared libraries produced as a result of this script will
            # not be copied from the builder image to the main one so build static
            if [ -x /modules/$module/prebuild ]; then 
                echo "Running prebuild script for $module"; 
                /modules/$module/prebuild; 
            fi; 
            /pkg-oss/build_module.sh -v $NGINX_VERSION -f -y -o /tmp/packages -n $module $(cat /modules/$module/source); 
            BUILT_MODULES="$BUILT_MODULES $(echo $module | tr '[A-Z]' '[a-z]' | tr -d '[/_-.t ]')"; 
        elif make -C /pkg-oss/debian list | grep -P "^$modules+d" > /dev/null; then 
            echo "Building $module from pkg-oss sources"; 
            cd /pkg-oss/debian; 
            make rules-module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION; 
            mk-build-deps --install --tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" debuild-module-$module/nginx-$NGINX_VERSION/debian/control; 
            make module-$module BASE_VERSION=$NGINX_VERSION NGINX_VERSION=$NGINX_VERSION; 
            find ../../ -maxdepth 1 -mindepth 1 -type f -name "*.deb" -exec mv -v {} /tmp/packages/ ;; 
            BUILT_MODULES="$BUILT_MODULES $module"; 
        else 
            echo "Don't know how to build $module module, exiting"; 
            exit 1; 
        fi; 
    done 
    && echo "BUILT_MODULES="$BUILT_MODULES"" > /tmp/packages/modules.env

FROM --platform=linux/amd64  ${NGINX_FROM_IMAGE}

RUN --mount=type=bind,target=/tmp/packages/,source=/tmp/packages/,from=builder 
    apt-get clean && apt-get update 
    && . /tmp/packages/modules.env 
    && echo "Built modules: $BUILT_MODULES" 
    && for module in $BUILT_MODULES; do 
           echo "Installing module: $module" 
           && ls -l /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb 
           && apt-get install --no-install-suggests --no-install-recommends -y /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb; 
       done 
    && rm -rf /var/lib/apt/lists/

I don’t understand why it manages to build my images one out of five times. Most of the time I end up with this error:

│ 2.396 Built modules:  subs-filter
│ 2.396 Installing module: subs-filter
│ 2.406 ls: cannot access '/tmp/packages/nginx-module-subs-filter_1.27.0*.deb': No such file or directory
│ ------
│ Dockerfile:76
│ --------------------
│   75 |     
│   76 | >>> RUN --mount=type=bind,target=/tmp/packages/,source=/tmp/packages/,from=builder 
│   77 | >>>     apt-get clean && apt-get update 
│   78 | >>>     && . /tmp/packages/modules.env 
│   79 | >>>     && echo "Built modules: $BUILT_MODULES" 
│   80 | >>>     && for module in $BUILT_MODULES; do 
│   81 | >>>            echo "Installing module: $module" 
│   82 | >>>            && ls -l /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb 
│   83 | >>>            && apt-get install --no-install-suggests --no-install-recommends -y /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb; 
│   84 | >>>        done 
│   85 | >>>     && rm -rf /var/lib/apt/lists/
│   86 |     
│ --------------------
│ ERROR: failed to solve: process "/bin/sh -c apt-get clean && apt-get update     && . /tmp/packages/modules.env     && echo "Built
│ modules: $BUILT_MODULES"     && for module in $BUILT_MODULES; do            echo "Installing module: $module"            && ls -l
│ /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb            && apt-get install --no-install-suggests
│ --no-install-recommends -y /tmp/packages/nginx-module-${module}_${NGINX_VERSION}*.deb;        done     && rm -rf
│ /var/lib/apt/lists/" did not complete successfully: exit code: 2 

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật