diff --git a/build.sh b/build.sh
index 0709f1f..28c7dbf 100755
--- a/build.sh
+++ b/build.sh
@@ -2,10 +2,15 @@
 
 set -euo pipefail
 
+function die() {
+    echo "$1"
+    exit 1
+}
+
 function build_image() {
     local dockerfile="$1"
     local image_name="${dockerfile//Dockerfile./}"
-    docker build -t "$image_name:latest" -f "$dockerfile" .
+    docker build -t "$image_name:latest" -f "$dockerfile" . || die "Failed to build $image_name"
 }
 
 pids=()