mirror of https://github.com/docker/cli.git
Merge pull request #3539 from thaJeztah/easier_make
Improvements to makefile and development container
This commit is contained in:
commit
9060ad6437
13
Makefile
13
Makefile
|
@ -9,6 +9,17 @@ all: binary
|
||||||
|
|
||||||
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
|
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
|
||||||
|
|
||||||
|
.PHONY: dev
|
||||||
|
dev: ## start a build container in interactive mode for in-container development
|
||||||
|
@if [ -n "${DISABLE_WARN_OUTSIDE_CONTAINER}" ]; then \
|
||||||
|
echo "you are already in the dev container"; \
|
||||||
|
else \
|
||||||
|
$(MAKE) -f docker.Makefile dev; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
shell: dev ## alias for dev
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## remove build artifacts
|
clean: ## remove build artifacts
|
||||||
rm -rf ./build/* man/man[1-9] docs/yaml
|
rm -rf ./build/* man/man[1-9] docs/yaml
|
||||||
|
@ -34,7 +45,7 @@ shellcheck: ## run shellcheck validation
|
||||||
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
|
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt: ## run gofmt
|
||||||
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
|
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
|
||||||
|
|
||||||
.PHONY: binary
|
.PHONY: binary
|
||||||
|
|
|
@ -35,7 +35,7 @@ DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_
|
||||||
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
|
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
|
||||||
|
|
||||||
.PHONY: binary
|
.PHONY: binary
|
||||||
binary:
|
binary: ## build executable
|
||||||
PACKAGER_NAME=$(PACKAGER_NAME) docker buildx bake binary
|
PACKAGER_NAME=$(PACKAGER_NAME) docker buildx bake binary
|
||||||
|
|
||||||
build: binary ## alias for binary
|
build: binary ## alias for binary
|
||||||
|
|
|
@ -29,8 +29,12 @@ RUN apk add --no-cache \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
coreutils \
|
coreutils \
|
||||||
curl \
|
curl \
|
||||||
git
|
git \
|
||||||
|
jq \
|
||||||
|
nano
|
||||||
|
|
||||||
|
RUN echo -e "\nYou are now in a development container. Run '\e\033[1mmake help\e\033[0m' to learn about\navailable make targets.\n" > /etc/motd \
|
||||||
|
&& echo -e "cat /etc/motd\nPS1=\"\e[0;32m\u@docker-cli-dev\\$ \e[0m\"" >> /root/.bashrc
|
||||||
CMD bash
|
CMD bash
|
||||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||||
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
|
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
|
||||||
|
|
|
@ -3,16 +3,25 @@ set -eu
|
||||||
|
|
||||||
target="${1:-}"
|
target="${1:-}"
|
||||||
|
|
||||||
if [ "$target" != "help" ] && [ -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]; then
|
if [ -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]; then
|
||||||
(
|
case $target in
|
||||||
echo
|
clean|dev|help|shell)
|
||||||
echo
|
# no warning needed for these targets
|
||||||
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
|
||||||
echo "Press Ctrl+C now to abort."
|
echo "\033[1mWARNING\033[0m: you are not in a container."
|
||||||
echo
|
echo
|
||||||
) >&2
|
echo 'Use "\033[1mmake dev\033[0m" to start an interactive development container,'
|
||||||
sleep 10
|
echo "use \"\033[1mmake -f docker.Makefile $target\033[0m\" to execute this target"
|
||||||
|
echo "in a container, or set \033[1mDISABLE_WARN_OUTSIDE_CONTAINER=1\033[0m to"
|
||||||
|
echo "disable this warning."
|
||||||
|
echo
|
||||||
|
echo "Press \033[1mCtrl+C\033[0m now to abort, or wait for the script to continue.."
|
||||||
|
echo
|
||||||
|
) >&2
|
||||||
|
sleep 5
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue