Skip to content

Commit 47e0a67

Browse files
authored
fix: Do not delete release image that is just built (#17951)
If building a release-image results in an image that already exists, then that image may not the most recent one. Which causes the image that was just built to be immediately untagged: ``` $ ./bootstrap.sh --- release-image build --- Cache download and extraction of release-image-base-23b1b4c058edacf1.zst complete in 17s. The image aztecprotocol/release-image-base:latest already exists, renaming the old one with ID sha256:eab31bb60893aeba8bc580463c3e1e871004fa8d261075fb214204e34897b2e6 to empty string Loaded image: aztecprotocol/release-image-base:latest [+] Building 2.4s (9/9) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 2.10kB 0.0s => [internal] load metadata for docker.io/aztecprotocol/release-image-base:latest 0.0s => [internal] load build context 2.3s => => transferring context: 454.61kB 2.3s => [1/5] FROM docker.io/aztecprotocol/release-image-base:latest 0.0s => CACHED [2/5] COPY . /usr/src 0.0s => CACHED [3/5] RUN mkdir -p /usr/src/bb /usr/src/acvm && chmod 777 /usr/src/bb /usr/src/acvm 0.0s => CACHED [4/5] WORKDIR /usr/src/yarn-project 0.0s => CACHED [5/5] RUN echo '{".": "'1fd7c0847f495ac2e9ffd701e7958d5893b6f897'"}' > /usr/src/.release-please-manifest.json 0.0s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:cdcb8e01b2139ca7cdcee3e195b6816fa924902b83acae79b6c26d0631efd462 0.0s => => naming to docker.io/aztecprotocol/aztec:1fd7c0847f495ac2e9ffd701e7958d5893b6f897 0.0s Untagged: aztecprotocol/aztec:1fd7c0847f495ac2e9ffd701e7958d5893b6f897 Untagged: aztecprotocol/aztec:latest Deleted: sha256:cdcb8e01b2139ca7cdcee3e195b6816fa924902b83acae79b6c26d0631efd462 ```
2 parents 5edda46 + 20227b6 commit 47e0a67

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

release-image/bootstrap.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ function build_image {
1616
# Otherwise, use the commit hash as the version.
1717
local version=$(git rev-parse HEAD)
1818
fi
19+
local previous_ids=$(docker images aztecprotocol/aztec --format "{{.ID}}" | uniq)
1920
docker build -f release-image/Dockerfile --build-arg VERSION=$version -t aztecprotocol/aztec:$(git rev-parse HEAD) .
2021
docker tag aztecprotocol/aztec:$(git rev-parse HEAD) aztecprotocol/aztec:latest
2122

22-
# Remove all but the most recent image.
23-
docker images aztecprotocol/aztec --format "{{.ID}}" | uniq | tail -n +2 | xargs -r docker rmi -f
23+
# If we actually built a new image (not from cache), remove all but the just-built image.
24+
local new_ids=$(docker images aztecprotocol/aztec --format "{{.ID}}" | uniq)
25+
if [ "$previous_ids" != "$new_ids" ]; then
26+
echo "$previous_ids" | xargs -r docker rmi -f
27+
fi
2428
}
2529
export -f build_image
2630

0 commit comments

Comments
 (0)