Make cleanup in jenkins build less aggressive, but remove all created tags

We've been deleting images by id and forcing removal, which might not play
nicely with other processes using images with shared parents. Now we don't force removal
and remove by tag and not by id, which should play more nicely with others. We also ensure
all the tags we use/create are removed so that images are actually deleted if not used.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2017-06-21 17:22:28 -07:00
parent f16c5d5e92
commit 829284e83a
2 changed files with 13 additions and 7 deletions

View File

@ -49,9 +49,14 @@ make ${MAKE_ARGS} \
DEPLOY_REGISTRY=registry.resinstaging.io/ \
deploy
# Cleanup removing by Id to actually remove the images rather than untagging them
docker rmi -f $(docker inspect -f "{{.Id}}" registry.resinstaging.io/resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME}) || true
docker rmi -f $(docker inspect -f "{{.Id}}" resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME}) || true
docker rmi -f $(docker inspect -f "{{.Id}}" ${NODE_SUPERVISOR_REPO}:${ESCAPED_BRANCH_NAME}) || true
docker rmi -f $(docker inspect -f "{{.Id}}" ${GO_SUPERVISOR_REPO}:${ESCAPED_BRANCH_NAME}) || true
docker rmi -f $(docker inspect -f "{{.Id}}" ${BASE_IMAGE_TAG}) || true
docker rmi registry.resinstaging.io/resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || true
docker rmi resin/${ARCH}-supervisor:${ESCAPED_BRANCH_NAME} || true
docker rmi resin/${ARCH}-supervisor:master || true
docker rmi ${NODE_SUPERVISOR_REPO}:${ESCAPED_BRANCH_NAME} || true
docker rmi ${NODE_SUPERVISOR_REPO}:master || true
docker rmi resin/node-supervisor-${ARCH}:${ESCAPED_BRANCH_NAME} || true
docker rmi ${GO_SUPERVISOR_REPO}:${ESCAPED_BRANCH_NAME} || true
docker rmi ${GO_SUPERVISOR_REPO}:master || true
docker rmi resin/go-supervisor-${ARCH}:${ESCAPED_BRANCH_NAME} || true
docker rmi ${BASE_IMAGE_TAG} || true
docker rmi ${BASE_IMAGE_REPO}:${ESCAPED_BRANCH_NAME} || true

View File

@ -48,7 +48,8 @@ docker run --rm \
-v $SSTATE_DIR:/yocto/shared-sstate \
-v `pwd`/dest:/dest \
${BUILDER_IMAGE}
docker rmi -f $(docker inspect -f "{{.Id}}" ${BUILDER_IMAGE}) || true
docker rmi ${BUILDER_IMAGE} || true
docker rmi ${BUILDER_REPO}:master || true
if [ -f dest/rootfs.tar.gz ]; then
docker import dest/rootfs.tar.gz ${BASE_IMAGE_TAG}
docker tag ${BASE_IMAGE_TAG} ${BASE_IMAGE_REPO}:${ESCAPED_BRANCH_NAME} || docker tag -f ${BASE_IMAGE_TAG} ${BASE_IMAGE_REPO}:${ESCAPED_BRANCH_NAME}