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 <[email protected]>
  • Loading branch information
hhromic committed Jul 30, 2023
1 parent 7b9f655 commit 024d651
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 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 @@ -128,6 +134,7 @@ define ENVIRONMENT_EXEC
endef


ifneq ($(CONTAINER_TOOL), unknown)
ifeq ($(ENVIRONMENT_AUTOBUILD), true)
define ENVIRONMENT_PREPARE
@echo "Building the environment. (ENVIRONMENT_AUTOBUILD=true) This may take a few minutes..."
Expand All @@ -142,6 +149,11 @@ define ENVIRONMENT_PREPARE
$(CONTAINER_TOOL) pull $(ENVIRONMENT_UPSTREAM)
endef
endif
else
define ENVIRONMENT_PREPARE
$(error "Please install a container tool such as Docker or Podman")
endef
endif

.PHONY: check-container-tool
check-container-tool: ## Checks what container tool is installed
Expand Down

0 comments on commit 024d651

Please sign in to comment.