Skip to content

Commit

Permalink
docker_run: run docker_build if the image does not exist
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Thomas Ballasi committed Oct 30, 2023
1 parent 6b96eff commit c69f520
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 1 addition & 2 deletions cqfd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tests/05-cqfd_run
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c69f520

Please sign in to comment.