Skip to content

Commit

Permalink
Also remove unused volumes during clean -p/postbuild.
Browse files Browse the repository at this point in the history
ty @r7l for the suggestion
  • Loading branch information
edannenberg committed Feb 18, 2019
1 parent dfb24ac commit 0cad470
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/argbash/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ print_help ()
{
printf 'Usage: %s clean [-b|--build-artifacts] [-p|--prune-dangling-images] [-i|--image-ns <arg>] [-I|--all-images] [-N|--nuke-from-orbit] [-w|--working-dir <arg>]\n' "${_KUBLER_BIN}"
printf "\t%s\n" "-b,--build-artifacts: Delete rootfs.tar, Dockerfile and PACKAGES.md files, this is the default and can be omitted"
printf "\t%s\n" "-p,--prune-dangling-images: Run docker image prune"
printf "\t%s\n" "-p,--prune-dangling-images: Run docker image/volume prune"
printf "\t%s\n" "-i,--image-ns: Delete all Docker images for given namespace (repeatable)"
printf "\t%s\n" "-I,--all-images: Delete all Kubler related images for all namespaces, except stage3 base images and portage"
printf "\t%s\n" "-N,--nuke-from-orbit: Same as activating all of the above options, also deletes stage3 base images and portage"
Expand Down
2 changes: 2 additions & 0 deletions cmd/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function main() {
source_build_engine 'docker'
_status_msg="exec docker image prune"
pwrap "${DOCKER}" image prune -f || die
_status_msg="exec docker volume prune"
pwrap "${DOCKER}" volume prune -f || die
msg_ok 'done.'
fi

Expand Down
7 changes: 5 additions & 2 deletions engine/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,11 @@ function build_image() {
_status_msg="tag image ${image_id}:latest"
pwrap 'nolog' "${DOCKER}" tag "${image_id}:${IMAGE_TAG}" "${image_id}:latest" || die "${_status_msg}"

_status_msg="remove untagged images"
pwrap "${DOCKER}" image prune -f
[[ "${KUBLER_POSTBUILD_IMAGE_PRUNE}" == 'true' ]] \
&& _status_msg="remove untagged images" && pwrap "${DOCKER}" image prune -f

[[ "${KUBLER_POSTBUILD_VOLUME_PRUNE}" == 'true' ]] \
&& _status_msg="remove unused volumes" && pwrap "${DOCKER}" volume prune -f

add_documentation_header "${image_id}" "${image_type}" || die "Failed to generate PACKAGES.md for ${image_id}"
local has_tests done_text
Expand Down
7 changes: 6 additions & 1 deletion kubler.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# Gentoo's binary package cache location
#KUBLER_PACKAGES_DIR="${KUBLER_DATA_DIR}/packages"

# Lock --working-dir to given path. If you enable this use an absolute path or ensure KUBLER_DATA_DIR above is set.
# Lock --working-dir to given path. If you enable this, it's not set per default, use an absolute path or ensure
# that KUBLER_DATA_DIR above is set.
#KUBLER_WORKING_DIR="${KUBLER_DATA_DIR}"

# Ouput related config
Expand All @@ -34,6 +35,10 @@
#KUBLER_DISABLE_KUBLER_NS='false'
# Effectively always enables -s for the build command
#KUBLER_DISABLE_GPG='false'
# Remove untagged/dangling images after each build
#KUBLER_POSTBUILD_IMAGE_PRUNE='true'
# Remove unused docker volumes after each build
#KUBLER_POSTBUILD_VOLUME_PRUNE='true'

# Portage snapshot date that is used to bootstrap the portage container, 'latest' is highly recommended
#PORTAGE_DATE='latest'
Expand Down
2 changes: 2 additions & 0 deletions lib/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ KUBLER_DOWNLOAD_DIR="${KUBLER_DOWNLOAD_DIR:-${KUBLER_DATA_DIR}/downloads}"
KUBLER_DISTFILES_DIR="${KUBLER_DISTFILES_DIR:-${KUBLER_DATA_DIR}/distfiles}"
KUBLER_PACKAGES_DIR="${KUBLER_PACKAGES_DIR:-${KUBLER_DATA_DIR}/packages}"
KUBLER_DEPGRAPH_IMAGE="${KUBLER_DEPGRAPH_IMAGE:-kubler/graph-easy}"
KUBLER_POSTBUILD_IMAGE_PRUNE="${KUBLER_POSTBUILD_IMAGE_PRUNE:-true}"
KUBLER_POSTBUILD_VOLUME_PRUNE="${KUBLER_POSTBUILD_VOLUME_PRUNE:-true}"

AUTHOR="${AUTHOR:-Erik Dannenberg <erik.dannenberg@xtrade-gmbh.de>}"

Expand Down

0 comments on commit 0cad470

Please sign in to comment.