From 1996be26751e41d77f07151291dc5e03b04d0899 Mon Sep 17 00:00:00 2001 From: g2flyer Date: Mon, 29 Jan 2024 10:27:50 -0800 Subject: [PATCH] fixup! Split docker makefile to move development targets into their own file --- docker/Makefile | 2 +- docker/make.dev | 36 ++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docker/Makefile b/docker/Makefile index 5a5590e9..cd0930bd 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -86,7 +86,7 @@ run_ccf : build_ccf stop_ccf run_services : build_base build_services_base build_services stop_services docker run $(DOCKER_RUN_ARGS) --name services_container -P -d pdo_services:$(PDO_VERSION) -run_client : build_base build_client +run_client : build_base build_client stop_client docker run $(DOCKER_RUN_ARGS) -it --name client_container pdo_client:$(PDO_VERSION) \ -c "stty cols $$(tput cols) rows $$(tput lines) && bash" diff --git a/docker/make.dev b/docker/make.dev index f373649b..e7c65d23 100644 --- a/docker/make.dev +++ b/docker/make.dev @@ -14,27 +14,43 @@ # limitations under the License. # ------------------------------------------------------------------------------ -# This file contains targets that are useful for running docker containers for -# development. Note that these are highly specific to individual developer -# tastes and can be modified as appropriate. +# This file, included in main Makefile, contains targets that are useful for running +# docker containers for development. Note that these are highly specific to individual +# developer tastes and can be modified as appropriate. DOCKER_DEV_CMD = stty cols $$(tput cols) rows $$(tput lines) && bash -DOCKER_DEV_ARGS = -v $(DOCKER_DIR)/xfer/:/project/pdo/xfer -DOCKER_DEV_ARGS += -v ${PDO_SOURCE_ROOT}/docker/tools/:/project/pdo/tools -DOCKER_DEV_ARGS += -v ${PDO_SOURCE_ROOT}/:/project/pdo/src -DOCKER_DEV_ARGS += --entrypoint=/bin/bash -it --network host +DOCKER_DEV_ARGS = $(DOCKER_RUN_ARGS) +DOCKER_DEV_ARGS += -v $(PDO_SOURCE_ROOT)/docker/tools/:/project/pdo/tools +DOCKER_DEV_ARGS += -v $(PDO_SOURCE_ROOT)/:/project/pdo/src +DOCKER_DEV_ARGS += --entrypoint=/bin/bash -it --rm + +# sharing a pip download cache on the host can be beneficial if you have to +# restart your container, e.g., for testing client contracts with large python +# dependencies. By default, we create a local cache dir but you can have it anywhere, +# e.g., in /tmp or even pointing ~/.cache/pip (although be aware that not pip does +# not necessarily guarantee cross-version compatibility!) +PIP_CACHE_DIR ?= $(DOCKER_DIR)/cache/pip +DOCKER_DEV_ARGS += -v $(PIP_CACHE_DIR):/project/pdo/.cache/pip + +# Docker runtime args specific to client +DOCKER_CLIENT_DEV_ARGS ?= +# - if you want pdo-contracts mounted in client dev image, define (e.g., in make.loc) +# variable 'DOCKER_CLIENT_WITH_PDO_CONTRACTS' +ifdef DOCKER_CLIENT_WITH_PDO_CONTRACTS + DOCKER_CLIENT_DEV_ARGS += -v $(DOCKER_DIR)/../../pdo-contracts.git:/project/pdo/contracts +endif run_ccf_dev : build_ccf - @ docker run $(DOCKER_DEV_ARGS) --name ccf_container_dev \ + docker run $(DOCKER_DEV_ARGS) --name ccf_container_dev \ -P pdo_ccf:$(PDO_VERSION) -c "$(DOCKER_DEV_CMD)" run_services_dev : build_base build_services_base build_services - @ docker run $(DOCKER_DEV_ARGS) --name services_container_dev \ + docker run $(DOCKER_DEV_ARGS) --name services_container_dev \ -P pdo_services:$(PDO_VERSION) -c "$(DOCKER_DEV_CMD)" run_client_dev : build_base build_client - @docker run $(DOCKER_DEV_ARGS) --name client_container_dev pdo_client:$(PDO_VERSION) \ + docker run $(DOCKER_CLIENT_DEV_ARGS) $(DOCKER_DEV_ARGS) --name client_container_dev pdo_client:$(PDO_VERSION) \ -c "$(DOCKER_DEV_CMD)" stop_all : stop_ccf_dev stop_services_dev stop_client_dev