This Bash script checks whether a given Docker image exists locally.
If not, it builds the image from a specified directory containing a Dockerfile.
Useful for CI/CD pipelines, local development automation, and repeatable builds.
- Docker installed and accessible in the system
$PATH - Bash (Unix-like shell)
./build_if_needed.sh <image-name[:tag]> <dockerfile-directory>