From b8e1c926643e8ce46278dc971184b5c394d2e08f Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 4 Apr 2024 07:49:21 -0400 Subject: [PATCH] make number of build cpus configurable --- .github/workflows/docker-publish.yml | 1 + Dockerfile | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3e01803..30fc236 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -55,6 +55,7 @@ jobs: with: context: . tags: ${{ steps.prepare_tag.outputs.image_id }}:${{ steps.prepare_tag.outputs.version }} + build-args: BUILD_CPUS=16 # For pull requests, export results to the build cache. # Otherwise, push to a registry. outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry,push=true' }} diff --git a/Dockerfile b/Dockerfile index a44c5ed..4b958a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ SHELL ["/bin/bash", "-c"] ENV PATH="/usr/local/bin:${PATH}" +ARG BUILD_CPUS=1 + COPY ./files/* /tmp/ RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \ @@ -98,22 +100,22 @@ RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \ && cd /usr/local/src/freeswitch/src \ && cp /tmp/switch_event.c . \ && cd /usr/local/src/libwebsockets \ - && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j 16 && make install \ + && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo && make -j${BUILD_CPUS} && make install \ && cd /usr/local/src/freeswitch/libs/libfvad && cp /tmp/configure.ac.libfvad configure.ac \ - && autoreconf -i && ./configure && make -j 16 && make install \ + && autoreconf -i && ./configure && make -j${BUILD_CPUS} && make install \ && cd /usr/local/src/freeswitch/libs/spandsp \ - && ./bootstrap.sh && ./configure && make -j 16 && make install \ + && ./bootstrap.sh && ./configure && make -j${BUILD_CPUS} && make install \ && cd /usr/local/src/freeswitch/libs/sofia-sip \ - && ./bootstrap.sh && ./configure && make -j 16 && make install \ + && ./bootstrap.sh && ./configure && make -j${BUILD_CPUS} && make install \ && cd /usr/local/src/freeswitch/libs/aws-c-common \ && mkdir -p build && cd build \ && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS="-Wno-unused-parameter" \ - && make -j 16 && make install \ + && make -j${BUILD_CPUS} && make install \ && cd /usr/local/src/freeswitch/libs/aws-sdk-cpp \ && git submodule update --init --recursive \ && mkdir -p build && cd build \ && cmake .. -DBUILD_ONLY="lexv2-runtime;transcribestreaming" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS="-Wno-unused-parameter -Wno-error=nonnull -Wno-error=deprecated-declarations -Wno-error=uninitialized -Wno-error=maybe-uninitialized" \ - && make -j 16 && make install \ + && make -j${BUILD_CPUS} && make -j${BUILD_CPUS} install \ && find /usr/local/src/freeswitch/libs/aws-sdk-cpp/ -type f -name "*.pc" | xargs cp -t /usr/local/lib/pkgconfig/ \ && echo building grpc \ && cd /usr/local/src/grpc \ @@ -121,24 +123,24 @@ RUN for i in $(seq 1 8); do mkdir -p "/usr/share/man/man${i}"; done \ && mkdir -p cmake/build \ && cd cmake/build \ && cmake -DBUILD_SHARED_LIBS=ON -DgRPC_SSL_PROVIDER=package -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ../.. \ - && make -j 16 \ + && make -j${BUILD_CPUS} \ && make install \ && cd /usr/local/src/freeswitch/libs/googleapis \ - && LANGUAGE=cpp FLAGS+='--experimental_allow_proto3_optional' make -j 16 \ + && LANGUAGE=cpp FLAGS+='--experimental_allow_proto3_optional' make -j${BUILD_CPUS} \ && cd /usr/local/src/freeswitch/libs/nuance-asr-grpc-api \ - && LANGUAGE=cpp make -j 16 \ + && LANGUAGE=cpp make -j${BUILD_CPUS} \ && cd /usr/local/src/freeswitch/libs/riva-asr-grpc-api \ - && LANGUAGE=cpp make -j 16 \ + && LANGUAGE=cpp make -j${BUILD_CPUS} \ && cd /usr/local/src/freeswitch/libs/soniox-asr-grpc-api \ - && LANGUAGE=cpp make -j 16 \ + && LANGUAGE=cpp make -j${BUILD_CPUS} \ && cd /usr/local/src/freeswitch/libs/cobalt-asr-grpc-api \ - && LANGUAGE=cpp make -j 16 \ + && LANGUAGE=cpp make -j${BUILD_CPUS} \ && sed -i '/#ifndef cJSON_AS4CPP__h/i #ifndef cJSON__h\n#define cJSON__h' /usr/local/include/aws/core/external/cjson/cJSON.h \ && echo '#endif' >> /usr/local/include/aws/core/external/cjson/cJSON.h \ && cd /usr/local/src/freeswitch \ && ./bootstrap.sh -j \ && ./configure --enable-tcmalloc=yes --with-lws=yes --with-extra=yes --with-aws=yes \ - && make -j 16 \ + && make -j${BUILD_CPUS} \ && make install \ && cp /tmp/acl.conf.xml /usr/local/freeswitch/conf/autoload_configs \ && cp /tmp/event_socket.conf.xml /usr/local/freeswitch/conf/autoload_configs \