Skip to content

Commit

Permalink
Merge pull request #4 from obgr/enhance/docker-core-count
Browse files Browse the repository at this point in the history
Enhance/docker core count
  • Loading branch information
eliasbakken authored Dec 3, 2023
2 parents 9996452 + 7c78052 commit cbb1c91
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

VERSION=$1
cores=$2 # Allow define No cores

case $VERSION in
barebone|mainsail|fluidd|octoprint|reflash)
Expand All @@ -12,9 +13,25 @@ case $VERSION in
echo "Wrong argument '$1'"
echo "Usage: $0 <barebone|mainsail|fluidd|octoprint|reflash>"
exit 1
;;
;;
esac

# Cores
reported_cores=$(nproc --all)
if [ ! -z $cores ] && [ $cores -gt $reported_cores ]; then
echo "😿 Desired core count greater than reported available cores."
elif [ ! -z $cores ] && [ $cores -lt 1 ]; then
echo "🙀 Desired core count cannot be less than 1"
fi

if [ -z "$cores" ] || [ $cores -gt $reported_cores ] || [ $cores -lt 1 ]; then
echo "😻 Allowing docker to use all available cores ($reported_cores)"
cores=$reported_cores # Set cores to reported number of cores
else
echo "😺 Allowing docker to use $cores cores"
cores=$reported_cores # Set cores to reported number of cores
fi

BUILD_DIR="../build-${VERSION}"
if ! test -d "$BUILD_DIR" ; then
echo "$BUILD_DIR missing"
Expand Down Expand Up @@ -42,7 +59,7 @@ cp armbian/watermark.png "${BUILD_DIR}"/packages/plymouth-theme-armbian/watermar
echo "${NAME}" > "${BUILD_DIR}"/userpatches/overlay/rebuild/rebuild-version

cd "$BUILD_DIR"
DOCKER_EXTRA_ARGS="--cpus=12" ./compile.sh rebuild
DOCKER_EXTRA_ARGS="--cpus=${cores}" ./compile.sh rebuild
IMG=$(ls -1 output/images/ | grep "img.xz$")

mv "$BUILD_DIR"/output/images/"$IMG" "../images/${NAME}.img.xz"
Expand Down

0 comments on commit cbb1c91

Please sign in to comment.