Skip to content

Commit

Permalink
CI: prune unused Docker images after use
Browse files Browse the repository at this point in the history
At the moment, we're running out of disk space when building packages in
Docker containers.  This is because our CI VMs have only 14 GB of
storage.  To help deal with this problem, let's add an option to the
run_dockers.bsh script to prune images after using them so we can free
some of that disk space and let the remaining jobs complete.
  • Loading branch information
bk2204 committed Apr 17, 2020
1 parent 8282419 commit 4a2e96b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -98,4 +98,4 @@ jobs:
- uses: actions/setup-ruby@v1
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
- run: (cd "$HOME/build-dockers" && ./build_dockers.bsh)
- run: DOCKER_AUTOPULL=0 ./docker/run_dockers.bsh
- run: DOCKER_AUTOPULL=0 ./docker/run_dockers.bsh --prune
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Expand Up @@ -70,7 +70,7 @@ jobs:
- run: gem install packagecloud-ruby
- run: git clone https://github.com/git-lfs/build-dockers.git "$HOME/build-dockers"
- run: (cd "$HOME/build-dockers" && ./build_dockers.bsh)
- run: DOCKER_AUTOPULL=0 ./docker/run_dockers.bsh
- run: DOCKER_AUTOPULL=0 ./docker/run_dockers.bsh --prune
# If this is a pre-release tag, don't upload anything to packagecloud.
- run: '[ -z "${GITHUB_REF%%refs/tags/*-pre*}" ] || ./script/packagecloud.rb'
env:
Expand Down
9 changes: 8 additions & 1 deletion docker/run_dockers.bsh
Expand Up @@ -42,8 +42,11 @@ function split_image_name()

# Parse Arguments
IMAGES=()
PRUNE=
while [[ $# > 0 ]]; do
if [ "$1" == "--" ]; then
if [ "$1" = "--prune" ]; then
PRUNE=t
elif [ "$1" == "--" ]; then
shift
DOCKER_CMD="${@}"
break
Expand Down Expand Up @@ -108,6 +111,10 @@ for IMAGE_NAME in "${IMAGES[@]}"; do
-v "${MINGW_PATCH}${IMAGE_REPO_DIR}:/repo" \
gitlfs/build-dockers:${IMAGE_NAME} ${DOCKER_CMD-}

if [ -n "$PRUNE" ]
then
$SUDO docker rmi -f "gitlfs/build-dockers:${IMAGE_NAME}"
fi
done

echo "Docker run completed successfully!"

0 comments on commit 4a2e96b

Please sign in to comment.