Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ci/container/container-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,19 @@ elif ! "${CONTAINER_CMD[@]}" image exists $IMAGE; then
fi

if [ "$DEVENV" = true ]; then
eprintln "Purging non-relevant container images"
"${CONTAINER_CMD[@]}" image prune -a -f --filter "reference!=$IMAGE"
# on the devenv we issue a warning if the images start taking up a lot of space.
# Podman does not have a dedicated layer cache like docker, so we avoid nuking dangling/unused images unless space becomes a concern;
# this allows new image builds to benefit from cached layers.
# We only issue a warning so that the user can GC when it's most convenient.
MAX_GB=20
images_rawsize=$(${CONTAINER_CMD[@]} system df --format json | jq -cMr '.[]|select(.Type == "Images")|.RawSize')
if (($images_rawsize > $MAX_GB * 10 ** 9)); then
tput -T xterm setaf 3
tput -T xterm bold
eprintln "Container images take up more than ${MAX_GB}GB. You can reclaim space by clearing the container image cache (will cause a rebuild):"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would probably make sense to print this after the container has run, otherwise users might be try to run the command from within the container

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although they might not see it then anymore since after exiting your session I would expect most users to also exit their terminal soon after.

eprintln "> ${CONTAINER_CMD[@]} image prune --all --force --filter containers=false"
tput -T xterm sgr0
fi
fi

WORKDIR="/ic"
Expand Down
Loading