$(shell command -v docker)
什么command
意思 它正在Makefile中使用。
我在我想了解的github存储库中看到了这一点。
看起来它正在使用命令设置变量以测试是否安装了docker,如果没有安装则停止构建,问题是我没有安装命令,并且尝试在ubuntu中安装命令,但是可以。找不到它,在Internet上查找如何安装此commad命令似乎真的很困难,因为它的名称,它how to install command in linux/ubuntu
没有带来任何有用的信息,还搜索了在Makefiles上使用此命令的方法,以寻求一些线索,但到目前为止没有任何帮助。
运行build命令似乎可以正常工作,因为它可以构建映像,是的,我已经安装了docker,但是仍然在终端中收到该消息 make: command: Command not found
任何想法?
生成构建输出(表示):
$ make build
make: command: Command not found
make: command: Command not found
docker build -t codelytv/typescript-ddd-skeleton:dev .
Sending build context to Docker daemon 1.023MB
.....
这是Makefile:
.PHONY = default deps build test start clean start-database
IMAGE_NAME := codelytv/typescript-ddd-skeleton
SERVICE_NAME := app
# Test if the dependencies we need to run this Makefile are installed
DOCKER := $(shell command -v docker)
DOCKER_COMPOSE := $(shell command -v docker-compose)
deps:
ifndef DOCKER
@echo "Docker is not available. Please install docker"
@exit 1
endif
ifndef DOCKER_COMPOSE
@echo "docker-compose is not available. Please install docker-compose"
@exit 1
endif
default: build
# Build image
build:
docker build -t $(IMAGE_NAME):dev .
# Run tests
test: build
docker-compose run --rm $(SERVICE_NAME) bash -c 'npm run build && npm run test'
# Start the application
start: build
docker-compose up $(SERVICE_NAME) && docker-compose down
# Clean containers
clean:
docker-compose down --rmi local --volumes --remove-orphans
# Start mongodb container in background
start_database:
docker-compose up -d mongo
这意味着编写此makefile的人不够谨慎,无法以可移植的方式编写它。
该command
命令是外壳程序的一部分(这就是为什么如果您在GNU make手册中查找该命令将看不到它的原因)。不仅如此,它还是bash shell的一部分:它不是POSIX sh标准命令。bash手册页说:
command [-pVv] command [arg ...]
Run command with args suppressing the normal shell function
lookup. Only builtin commands or commands found in the PATH are
executed.
基本上,运行command docker ...
意味着将docker
忽略任何命名的shell别名或函数,并且仅docker
运行实际命令。
但是,GNU make始终/bin/sh
作为其外壳运行,包括用于配方和$(shell ...)
功能。
因此,如果您使用的/bin/sh
是bash外壳程序的链接的系统(例如Red Hat或CentOS或Fedora GNU / Linux),那么上面的命令将起作用。
但是,如果您使用的系统(例如Debian或Ubuntu GNU / Linux)/bin/sh
链接到更简单的POSIX shell(例如破折号),则上述命令将不起作用。
实际上,这是不需要的,因为无论如何,在shell中定义的所有shell别名或函数都不会进行调用。但是,如果作者想要在其makefile中使用bash shell功能并允许它们工作,他们还需要通过将make添加到其makefile中来告知make使用bash作为其shell:
SHELL := /bin/bash
(当然,这假设用户/bin/bash
的系统上有一个,但是...)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句