Skip to content

Commit

Permalink
fix(dev): fix detection of container tool in make
Browse files Browse the repository at this point in the history
Fixes the following error when `ENVIRONMENT=true` and neither Docker or Podman are available:

    make: podman: No such file or directory
    make: *** [Makefile:174: build] Error 127

Podman was being used as fallback even if also not available.
A descriptive error is now reported instead in this situation.

Signed-off-by: Hugo Hromic <hhromic@gmail.com>
  • Loading branch information
hhromic committed Jul 30, 2023
1 parent 7b9f655 commit 2479e2f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export VERBOSE ?= false
# Override the container tool. Tries docker first and then tries podman.
export CONTAINER_TOOL ?= auto
ifeq ($(CONTAINER_TOOL),auto)
override CONTAINER_TOOL = $(shell docker version >/dev/null 2>&1 && echo docker || echo podman)
ifeq ($(shell docker version >/dev/null 2>&1 && echo docker), docker)
override CONTAINER_TOOL = docker
else ifeq ($(shell podman version >/dev/null 2>&1 && echo podman), podman)
override CONTAINER_TOOL = podman
else
override CONTAINER_TOOL = unknown
endif
endif
# If we're using podman create pods else if we're using docker create networks.
export CURRENT_DIR = $(shell pwd)
Expand Down Expand Up @@ -108,6 +114,9 @@ endif

# We use a volume here as non-Linux hosts are extremely slow to share disks, and Linux hosts tend to get permissions clobbered.
define ENVIRONMENT_EXEC
ifeq $($(CONTAINER_TOOL), unknown)
$(error "Please install a container tool such as Docker or Podman")
endif
${ENVIRONMENT_PREPARE}
@echo "Entering environment..."
@mkdir -p target
Expand Down

0 comments on commit 2479e2f

Please sign in to comment.