From 99d36ec791974434d5feb9bb483f92e7db9e44dd Mon Sep 17 00:00:00 2001 From: Thomas Ballasi Date: Fri, 27 Oct 2023 19:26:24 -0400 Subject: [PATCH] docker_run: run docker_build if the image does not exist As an effort to make cqfd run similarily to known tools, such as sudo, the docker image is automatically built if necessary rather than dying. --- README.md | 1 - cqfd | 3 +-- tests/05-cqfd_run | 5 ++++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 91d04b2..d5e0678 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ Just follow these steps: * Go into your project's directory * Create a .cqfdrc file * Put a Dockerfile and save it as .cqfd/docker/Dockerfile -* Run ``cqfd --init`` Examples are available in the samples/ directory. diff --git a/cqfd b/cqfd index 72ac622..9f38ebc 100755 --- a/cqfd +++ b/cqfd @@ -187,9 +187,8 @@ docker_build() { # arg$1: the command string to execute as $cqfd_user # docker_run() { - if ! docker image inspect $docker_img_name &> /dev/null; then - die "The docker image doesn't exist, launch 'cqfd --init' to create it" + docker_build fi local interactive_options diff --git a/tests/05-cqfd_run b/tests/05-cqfd_run index 3a35750..dddb526 100755 --- a/tests/05-cqfd_run +++ b/tests/05-cqfd_run @@ -42,8 +42,11 @@ done ################################################################################ jtest_prepare "Modifying the Dockerfile should require running 'cqfd --init' again" dockerfile=.cqfd/docker/Dockerfile +prev_img_count=$(docker images | grep cqfd_test | wc -l) echo "RUN echo $RANDOM" >> $dockerfile -if $TDIR/.cqfd/cqfd; then +$cqfd +new_img_count=$(docker images | grep cqfd_test | wc -l) +if [ "$prev_img_count" -eq "$new_img_count" ]; then jtest_result fail else jtest_result pass