From e250c83c21c2130c8b26a55c9500e5f0677effbd Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Thu, 17 Jan 2019 16:14:58 -0800 Subject: [PATCH] Add BUILD_CONCURRENCY argument so that we can limit concurrency on Docker Hub (and thus reduce peak memory need for build) --- docker/Dockerfile | 3 ++- docker/hooks/build | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9da5d43f8..056f8c7b6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,11 @@ FROM debian:stretch-slim as builder ARG DOCKER_TAG +ARG BUILD_CONCURRENCY RUN mkdir -p /src && mkdir -p /opt COPY . /src WORKDIR /src -RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ +RUN NPROC=${BUILD_CONCURRENCY:-$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1)} && \ apt-get update && \ apt-get -y --no-install-recommends install cmake make git gcc g++ libbz2-dev libxml2-dev \ libzip-dev libboost1.62-all-dev lua5.2 liblua5.2-dev libtbb-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 && \ diff --git a/docker/hooks/build b/docker/hooks/build index d1eac8ab0..c27c851ad 100644 --- a/docker/hooks/build +++ b/docker/hooks/build @@ -6,4 +6,4 @@ # ensure that "COPY . /src" is referring to the repo root, not the directory # that contains the Dockerfile. # This script gets executed with a pwd of wherever the Dockerfile is. -docker build --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile .. +docker build --build-arg BUILD_CONCURRENCY=${CONCURRENCY:-1} --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile ..