mirror of https://github.com/docker/cli.git
Add a warning when make is run outside of a container.
The warning can be disabled by setting the environment variable Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
2dac00bdca
commit
12a7387c8e
2
Makefile
2
Makefile
|
@ -4,6 +4,8 @@
|
||||||
all: binary
|
all: binary
|
||||||
|
|
||||||
|
|
||||||
|
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## remove build artifacts
|
clean: ## remove build artifacts
|
||||||
rm -rf ./build/* cli/winresources/rsrc_* ./man/man[1-9] docs/yaml/gen
|
rm -rf ./build/* cli/winresources/rsrc_* ./man/man[1-9] docs/yaml/gen
|
||||||
|
|
|
@ -10,7 +10,7 @@ CROSS_IMAGE_NAME = docker-cli-cross
|
||||||
VALIDATE_IMAGE_NAME = docker-cli-shell-validate
|
VALIDATE_IMAGE_NAME = docker-cli-shell-validate
|
||||||
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
||||||
VERSION = $(shell cat VERSION)
|
VERSION = $(shell cat VERSION)
|
||||||
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT
|
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||||
|
|
||||||
# build docker image (dockerfiles/Dockerfile.build)
|
# build docker image (dockerfiles/Dockerfile.build)
|
||||||
.PHONY: build_docker_image
|
.PHONY: build_docker_image
|
||||||
|
@ -39,12 +39,12 @@ build: binary
|
||||||
# clean build artifacts using a container
|
# clean build artifacts using a container
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: build_docker_image
|
clean: build_docker_image
|
||||||
docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
|
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
|
||||||
|
|
||||||
# run go test
|
# run go test
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build_docker_image
|
test: build_docker_image
|
||||||
docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make test
|
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make test
|
||||||
|
|
||||||
# build the CLI for multiple architectures using a container
|
# build the CLI for multiple architectures using a container
|
||||||
.PHONY: cross
|
.PHONY: cross
|
||||||
|
@ -53,24 +53,26 @@ cross: build_cross_image
|
||||||
|
|
||||||
.PHONY: watch
|
.PHONY: watch
|
||||||
watch: build_docker_image
|
watch: build_docker_image
|
||||||
docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make watch
|
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make watch
|
||||||
|
|
||||||
# start container in interactive mode for in-container development
|
# start container in interactive mode for in-container development
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
dev: build_docker_image
|
dev: build_docker_image
|
||||||
docker run -ti $(MOUNTS) -v /var/run/docker.sock:/var/run/docker.sock $(DEV_DOCKER_IMAGE_NAME) ash
|
docker run -ti $(ENVVARS) $(MOUNTS) \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
$(DEV_DOCKER_IMAGE_NAME) ash
|
||||||
|
|
||||||
shell: dev
|
shell: dev
|
||||||
|
|
||||||
# run linters in a container
|
# run linters in a container
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: build_linter_image
|
lint: build_linter_image
|
||||||
docker run -ti $(MOUNTS) $(LINTER_IMAGE_NAME)
|
docker run -ti $(ENVVARS) $(MOUNTS) $(LINTER_IMAGE_NAME)
|
||||||
|
|
||||||
# download dependencies (vendor/) listed in vendor.conf, using a container
|
# download dependencies (vendor/) listed in vendor.conf, using a container
|
||||||
.PHONY: vendor
|
.PHONY: vendor
|
||||||
vendor: build_docker_image vendor.conf
|
vendor: build_docker_image vendor.conf
|
||||||
docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor
|
||||||
|
|
||||||
dynbinary: build_cross_image
|
dynbinary: build_cross_image
|
||||||
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(CROSS_IMAGE_NAME) make dynbinary
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(CROSS_IMAGE_NAME) make dynbinary
|
||||||
|
@ -78,13 +80,13 @@ dynbinary: build_cross_image
|
||||||
## generate man pages from go source and markdown
|
## generate man pages from go source and markdown
|
||||||
.PHONY: manpages
|
.PHONY: manpages
|
||||||
manpages: build_docker_image
|
manpages: build_docker_image
|
||||||
docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make manpages
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make manpages
|
||||||
|
|
||||||
## Generate documentation YAML files consumed by docs repo
|
## Generate documentation YAML files consumed by docs repo
|
||||||
.PHONY: yamldocs
|
.PHONY: yamldocs
|
||||||
yamldocs: build_docker_image
|
yamldocs: build_docker_image
|
||||||
docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make yamldocs
|
||||||
|
|
||||||
.PHONY: shellcheck
|
.PHONY: shellcheck
|
||||||
shellcheck: build_shell_validate_image
|
shellcheck: build_shell_validate_image
|
||||||
docker run -ti --rm $(MOUNTS) $(VALIDATE_IMAGE_NAME) make shellcheck
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(VALIDATE_IMAGE_NAME) make shellcheck
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
target="${1:-}"
|
||||||
|
|
||||||
|
if [[ -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]]; then
|
||||||
|
(
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "WARNING: you are not in a container."
|
||||||
|
echo "Use \"make -f docker.Makefile $target\" or set"
|
||||||
|
echo "DISABLE_WARN_OUTSIDE_CONTAINER=1 to disable this warning."
|
||||||
|
echo
|
||||||
|
echo "Press Ctrl+C now to abort."
|
||||||
|
echo
|
||||||
|
) >&2
|
||||||
|
sleep 10
|
||||||
|
fi
|
Loading…
Reference in New Issue