Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions bin/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ build_image()
fi

if [ "${type}" == 'server' ]; then
# Create latest tag for image build cache
docker tag "${image_name}" "${CYBER_DOJO_DIFFER_IMAGE}:latest"
# Tag image-name for local development where differs name comes from echo-versioner-env-vars
docker tag "${image_name}" "cyberdojo/differ:${CYBER_DOJO_DIFFER_TAG}"
# After tagging, so removing an earlier build's tags takes its last tag with
# them and the image itself goes, rather than being left dangling when
# :latest moves to this build. check_args rejects 'server' inside CI, so the
# image pulled by the 'Download docker image' CI job is never at risk here.
# After tagging, so this build is protected by its own tag, and removing an
# earlier build's tags takes its last tag with them and the image itself
# goes. check_args rejects 'server' inside CI, so the image pulled by the
# 'Download docker image' CI job is never at risk here.
remove_old_images
echo
echo " echo CYBER_DOJO_DIFFER_SHA=${CYBER_DOJO_DIFFER_SHA}"
Expand Down
8 changes: 3 additions & 5 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ remove_old_images()
remove_all_but_current "${dil}" cyberdojo/differ
}

# Keeps :latest, which preserves the image-layer build cache, and this commit's
# tag, which names the build just made. Every older tag goes, and an earlier
# build whose last tag was one of those goes with it.
# Keeps this commit's tag, which names the build just made. Every older tag
# goes, and an earlier build whose last tag was one of those goes with it.
remove_all_but_current()
{
local -r docker_image_ls="${1}"
Expand All @@ -115,8 +114,7 @@ remove_all_but_current()
local tagged_name
for tagged_name in $(echo "${docker_image_ls}" | grep "${name}:" || true)
do
if [ "${tagged_name}" != "${name}:latest" ] \
&& [ "${tagged_name}" != "${name}:${CYBER_DOJO_DIFFER_TAG}" ]; then
if [ "${tagged_name}" != "${name}:${CYBER_DOJO_DIFFER_TAG}" ]; then
docker image rm --force "${tagged_name}" || echo " skipped ${tagged_name} (in use)"
fi
done
Expand Down
Loading