Skip to content

Commit bdd6ce2

Browse files
authored
Merge pull request ceph#62021 from dmick/container-rmi-tags
container/build.sh: remove local container images
2 parents de4b932 + 642e5f2 commit bdd6ce2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

container/build.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# repo auth with write perms must be present (this script does not log into
55
# repos named by CONTAINER_REPO_*).
66
# If NO_PUSH is set, no login is necessary
7+
# If REMOVE_LOCAL_IMAGES is true (the default), local images are removed
8+
# after push. If you want to save local image copies, set this to false.
79

810

911
CFILE=${1:-Containerfile}
@@ -25,11 +27,13 @@ CONTAINER_REPO_USERNAME
2527
CONTAINER_REPO_PASSWORD
2628
PRERELEASE_USERNAME for download.ceph.com:/prerelease/ceph
2729
PRERELEASE_PASSWORD
30+
REMOVE_LOCAL_IMAGES set to 'false' if you want to keep local images
2831
2932
For a release build: (from ceph.git, built and pushed to download.ceph.com)
3033
CI_CONTAINER: must be 'false'
3134
and you must also add
3235
VERSION (for instance, 19.1.0) for tagging the image
36+
REMOVE_LOCAL_IMAGES set to 'false' if you want to keep local images
3337
3438
You can avoid the push step (for testing) by setting NO_PUSH to anything
3539
EOF
@@ -48,6 +52,7 @@ REPO_ARCH=amd64
4852
if [[ "${ARCH}" = arm64 ]] ; then
4953
REPO_ARCH=arm64
5054
fi
55+
REMOVE_LOCAL_IMAGES=${REMOVE_LOCAL_IMAGES:-true}
5156

5257
if [[ ${CI_CONTAINER} == "true" ]] ; then
5358
CONTAINER_REPO_HOSTNAME=${CONTAINER_REPO_HOSTNAME:-quay.ceph.io}
@@ -67,6 +72,7 @@ fi
6772
: "${BRANCH:?}"
6873
: "${CEPH_SHA1:?}"
6974
: "${ARCH:?}"
75+
: "${REMOVE_LOCAL_IMAGES:?}"
7076
if [[ ${NO_PUSH} != "true" ]] ; then
7177
: "${CONTAINER_REPO_HOSTNAME:?}"
7278
: "${CONTAINER_REPO_ORGANIZATION:?}"
@@ -173,6 +179,9 @@ if [[ ${CI_CONTAINER} == "true" ]] ; then
173179
podman tag ${image_id} ${sha1_flavor_repo_tag}
174180
if [[ -z "${NO_PUSH}" ]] ; then
175181
podman push ${sha1_flavor_repo_tag}
182+
if [[ ${REMOVE_LOCAL_IMAGES} == "true" ]] ; then
183+
podman rmi -f ${sha1_flavor_repo_tag}
184+
fi
176185
fi
177186
exit
178187
fi
@@ -181,6 +190,9 @@ if [[ ${CI_CONTAINER} == "true" ]] ; then
181190
podman push ${full_repo_tag}
182191
podman push ${branch_repo_tag}
183192
podman push ${sha1_repo_tag}
193+
if [[ ${REMOVE_LOCAL_IMAGES} == "true" ]] ; then
194+
podman rmi -f ${full_repo_tag} ${branch_repo_tag} ${sha1_repo_tag}
195+
fi
184196
fi
185197
else
186198
#
@@ -192,7 +204,9 @@ else
192204
podman tag ${image_id} ${version_tag}
193205
if [[ -z "${NO_PUSH}" ]] ; then
194206
podman push ${version_tag}
207+
if [[ ${REMOVE_LOCAL_IMAGES} == "true" ]] ; then
208+
podman rmi -f ${version_tag}
209+
fi
195210
fi
196211
fi
197212

198-

0 commit comments

Comments
 (0)