Skip to content

Commit

Permalink
Fix storage location of Docker images and containers for Mac or linux (
Browse files Browse the repository at this point in the history
…project-chip#21046)

* Fix storage location of Docker images and containers for osx or linux
This will fix information about used memory space when build image of docker on osx host machine. Docker has another directory on linux and osx.

* Fixed styling problem

* Improved system checking and path mapping for docker volume
  • Loading branch information
DamMicSzm authored and isiu-apple committed Sep 16, 2022
1 parent 73fec9d commit e55a1a5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions integrations/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ IMAGE=${DOCKER_BUILD_IMAGE:-$(basename "$(pwd)")}
# version
VERSION=${DOCKER_BUILD_VERSION:-$(sed 's/ .*//' version)}

if [[ $OSTYPE == 'darwin'* ]]; then
DOCKER_VOLUME_PATH=~/Library/Containers/com.docker.docker/Data/vms/0/
else
DOCKER_VOLUME_PATH=/var/lib/docker/
fi

[[ ${*/--help//} != "${*}" ]] && {
set +x
echo "Usage: $me <OPTIONS>
Expand All @@ -59,7 +65,7 @@ set -ex

[[ -n $VERSION ]] || die "version cannot be empty"

mb_space_before=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}')
mb_space_before=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}')

# go find and build any CHIP images this image is "FROM"
awk -F/ '/^FROM connectedhomeip/ {print $2}' Dockerfile | while read -r dep; do
Expand Down Expand Up @@ -92,8 +98,9 @@ docker image prune --force
}

docker images --filter=reference="$ORG/*"
df -h /var/lib/docker/
mb_space_after=$(df -m /var/lib/docker/ | awk 'FNR==2{print $3}')
df -h "$DOCKER_VOLUME_PATH"
mb_space_after=$(df -m "$DOCKER_VOLUME_PATH" | awk 'FNR==2{print $3}')

printf "%'.f MB total used\n" "$((mb_space_before - mb_space_after))"

exit 0

0 comments on commit e55a1a5

Please sign in to comment.