Skip to content

Commit e3fb9b1

Browse files
authored
feat: attempt to pull docker image before building it (#1218)
The docker/podman image was always built from scratch before even though a precompiled version is automatically uploaded to Docker Hub. This attempts to pull the prebuilt image and only builds it from scratch if that fails.
1 parent 7e6266d commit e3fb9b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bin/setup

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ if [ -v GITHUB_ACTIONS ]; then
115115
sudo sysctl --system
116116
elif [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
117117
if ! ${CONTAINER_TYPE} images riscvintl/udb:${CONTAINER_TAG} | grep -q udb ; then
118-
# TODO: pull the image if it can be found
119-
echo "Building ${CONTAINER_TYPE} image..."
120-
${CONTAINER_TYPE} build -t riscvintl/udb:${CONTAINER_TAG} -f .devcontainer/Dockerfile .
118+
echo "Image not found locally. Attempting to pull from registry..."
119+
if ${CONTAINER_TYPE} pull docker.io/riscvintl/udb:${CONTAINER_TAG} 2>/dev/null; then
120+
echo "Successfully pulled image from registry."
121+
else
122+
echo "Could not pull image from registry. Building locally..."
123+
${CONTAINER_TYPE} build -t riscvintl/udb:${CONTAINER_TAG} -f .devcontainer/Dockerfile .
124+
fi
121125
fi
122126
if [ ${CONTAINER_TYPE} == "podman" ]; then
123127
# Podman requires extra flags to handle SELinux

0 commit comments

Comments
 (0)