From 98a942469134fcc3f91b6658a6fbb256d9d89518 Mon Sep 17 00:00:00 2001 From: Jose Lausuch Date: Wed, 13 Dec 2017 15:51:23 +0100 Subject: Clean Docker images after builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compared to the related Releng script, it only focuses on cleaning images. It's considered out of scope to remove remaining docker containers. It doesn't force to remove images because base images (e.g. Alpine) could be selected by other OPNFV projects too. It ensures O is returned even if one image cannot be removed. functest-core is removed at the end because all Functest containers depend on it. The script works well in a nominal building env. Any remaining Functest images or containers must be removed by hand. JIRA: FUNCTEST-898 Co-Authored-By: Cédric Ollivier Change-Id: I72d8214b711680ec7958af1d427b23dee6337bf6 Signed-off-by: Jose Lausuch Signed-off-by: Cédric Ollivier --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index 9041615cc..f9a94652e 100644 --- a/build.sh +++ b/build.sh @@ -20,7 +20,9 @@ find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest- for dir in ${amd64_dirs}; do (cd "${dir}" && docker build "${build_opts[@]}" -t "${repo}/functest-${dir##**/}:amd64-latest" .) docker push "${repo}/functest-${dir##**/}:amd64-latest" + [ "${dir}" != "docker/core" ] && docker rmi "${repo}/functest-${dir##**/}:amd64-latest" || true done +docker rmi "${repo}/functest-core:amd64-latest" alpine:3.6 || true find . -name Dockerfile -exec git checkout {} + find . -name Dockerfile -exec sed -i -e "s|alpine:3.6|multiarch/alpine:arm64-v3.6|g" {} + @@ -28,7 +30,9 @@ find . -name Dockerfile -exec sed -i -e "s|opnfv/functest-core|${repo}/functest- for dir in ${arm64_dirs}; do (cd "${dir}" && docker build "${build_opts[@]}" -t "${repo}/functest-${dir##**/}:arm64-latest" .) docker push "${repo}/functest-${dir##**/}:arm64-latest" + [ "${dir}" != "docker/core" ] && docker rmi "${repo}/functest-${dir##**/}:arm64-latest" || true done +docker rmi "${repo}/functest-core:arm64-latest" multiarch/alpine:arm64-v3.6 || true find . -name Dockerfile -exec git checkout {} + exit $? -- cgit 1.2.3-korg