Explorar o código

HPCC-23779 Pick up environment variable for number of build threads

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith %!s(int64=5) %!d(string=hai) anos
pai
achega
e70f582f63

+ 5 - 0
dockerfiles/buildall.sh

@@ -45,6 +45,10 @@ if [[ -n ${INPUT_USERNAME} ]] ; then
   PUSH=1
 fi
 
+if [[ -n ${INPUT_BUILD_THREADS} ]] ; then
+  BUILD_THREADS=$INPUT_BUILD_THREADS
+fi
+
 if [[ -z ${BUILD_TAG} ]] ; then
   echo Current tag could not be located
   echo Perhaps you meant to run incr.sh ?
@@ -68,6 +72,7 @@ build_image() {
        --build-arg BUILD_LABEL=${BUILD_LABEL} \
        --build-arg BUILD_USER=${BUILD_USER} \
        --build-arg BUILD_TYPE=${BUILD_TYPE} \
+       --build-arg BUILD_THREADS=${BUILD_THREADS} \
        ${name}/ 
     if [ "$PUSH" = "1" ] ; then
       docker push hpccsystems/${name}:${label}

+ 2 - 2
dockerfiles/incr.sh

@@ -35,13 +35,13 @@ PREV=$1
 
 BUILD_TYPE=Debug
 BUILD_LABEL=${HEAD}-Debug${DIRTY}
+BUILD_THREADS=$INPUT_BUILD_THREADS
 
 if [[ "$BUILD_LABEL" == "$PREV" ]] ; then
     echo Docker image hpccsystems/platform-core:${HEAD} already exists
     PREV=$(git log --format=format:%h-Debug $(git describe --abbrev=0 --tags)..HEAD | grep `docker images hpccsystems/platform-build --format {{.Tag}} | head -n 2 | tail -n 1`)
     [[ -z ${PREV} ]] && PREV=$(git describe --abbrev=0 --tags)-Debug
 fi
-
 set -e
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -56,7 +56,7 @@ else
   git diff --binary ${PREV_COMMIT} ':!./' > platform-build-incremental/hpcc.gitpatch
   # PATCH_MD5 is an ARG of the docker file, which ensures that if different from cached version, image will rebuild from that stage
   PATCH_MD5=$(md5sum platform-build-incremental/hpcc.gitpatch  | awk '{print $1}')
-  docker image build -t hpccsystems/platform-build:${BUILD_LABEL} --build-arg PREV_LABEL=${PREV} --build-arg PATCH_MD5=${PATCH_MD5} platform-build-incremental/
+  docker image build -t hpccsystems/platform-build:${BUILD_LABEL} --build-arg PREV_LABEL=${PREV} --build-arg PATCH_MD5=${PATCH_MD5} --build-arg BUILD_THREADS=${BUILD_THREADS} platform-build-incremental/
   rm platform-build-incremental/hpcc.gitpatch
 fi
 docker image build -t hpccsystems/platform-core:${BUILD_LABEL} --build-arg BUILD_LABEL=${BUILD_LABEL} platform-core-debug/  

+ 6 - 2
dockerfiles/platform-build-incremental/Dockerfile

@@ -37,7 +37,11 @@ COPY hpcc.gitpatch .
 RUN if [ -s hpcc.gitpatch ]; then git apply --whitespace=nowarn hpcc.gitpatch; fi
 
 WORKDIR /hpcc-dev/build
-RUN make -j$(($(nproc)*3/2))
+ARG BUILD_THREADS
+RUN if [ -n "${BUILD_THREADS}" ] ; then echo ${BUILD_THREADS} > ~/build_threads; else echo $(($(nproc)*3/2)) > ~/build_threads ; fi
+RUN echo Building with $(cat ~/build_threads) threads
+RUN make -j$(cat ~/build_threads)
 
 USER root
-RUN make -j$(($(nproc)*3/2)) install
+RUN make -j$(cat ~hpcc/build_threads) install
+

+ 9 - 6
dockerfiles/platform-build/Dockerfile

@@ -50,15 +50,18 @@ WORKDIR /hpcc-dev/build
 ARG BUILD_TYPE=RelWithDebInfo
 RUN cmake /hpcc-dev/HPCC-Platform -Wno-dev -DCONTAINERIZED=1 -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
 
-RUN make -j$(nproc) jlib
-RUN make -j$(nproc) esp
-RUN make -j$(nproc) roxie
-RUN make -j$(nproc) ws_workunits ecl
-RUN make -j$(nproc)
+ARG BUILD_THREADS
+RUN if [ -n "${BUILD_THREADS}" ] ; then echo ${BUILD_THREADS} > ~/build_threads; else echo $(nproc) > ~/build_threads ; fi
+RUN echo Building with $(cat ~/build_threads) threads
+RUN make -j$(cat ~/build_threads) jlib
+RUN make -j$(cat ~/build_threads) esp
+RUN make -j$(cat ~/build_threads) roxie
+RUN make -j$(cat ~/build_threads) ws_workunits ecl
+RUN make -j$(cat ~/build_threads)
 
 USER root
 
-RUN make -j$(nproc) install
+RUN make -j$(cat ~hpcc/build_threads) install
 RUN mkdir /var/lib/HPCCSystems && chown hpcc:hpcc /var/lib/HPCCSystems
 RUN mkdir /var/log/HPCCSystems && chown hpcc:hpcc /var/log/HPCCSystems
 RUN mkdir /var/lock/HPCCSystems && chown hpcc:hpcc /var/lock/HPCCSystems