diff --git a/docker/Makefile b/docker/Makefile index 45a9e44c..5cfd6295 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -25,6 +25,8 @@ PDO_REPO ?= ${PDO_SOURCE_ROOT} PDO_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) +PDO_VERSION ?= $(shell cd repository; bin/get_version) + # PDO_USER_UID, PDO_GROUP_UID -- # The UID/GID for the user accounts that will be created in the container; this is # important especially when the containers are being used for development; note @@ -58,31 +60,38 @@ all : $(addprefix build_,$(IMAGES)) rebuild_% : repository @ docker build $(DOCKER_ARGS) \ --build-arg REBUILD=$(TIMESTAMP) \ - --build-arg PDO_VERSION=$(shell cd repository; bin/get_version) \ - --tag pdo_$*:$(shell cd repository; bin/get_version) \ + --build-arg PDO_VERSION=${PDO_VERSION} \ + --tag pdo_$*:${PDO_VERSION} \ --file $(SCRIPT_DIR)/pdo_$*.dockerfile . build_% : repository @ docker build $(DOCKER_ARGS) \ - --build-arg PDO_VERSION=$(shell cd repository; bin/get_version) \ - --tag pdo_$*:$(shell cd repository; bin/get_version) \ + --build-arg PDO_VERSION=${PDO_VERSION} \ + --tag pdo_$*:${PDO_VERSION} \ --file $(SCRIPT_DIR)/pdo_$*.dockerfile . clean_% : - @ docker rmi -f pdo_$* + @ docker rmi -f pdo_$*:${PDO_VERSION} + +run_ccf : build_ccf stop_ccf + @ docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer --network host --name ccf_container -P -d pdo_ccf:${PDO_VERSION} + +run_services : build_base build_services_base build_services stop_services + @ docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer --network host --name services_container -P -d pdo_services:${PDO_VERSION} -run_ccf : build_ccf +run_client : build_base build_client stop_client + @docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer -it --network host --name client_container pdo_client:${PDO_VERSION} -c "stty cols $$(tput cols) rows $$(tput lines) && bash" + +stop_all : stop_ccf stop_services stop_client + +stop_ccf : - docker rm -f ccf_container - @ docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer --network host --name ccf_container -P -d pdo_ccf -run_services : build_base build_services_base build_services +stop_services : - docker rm -f services_container - @ docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer --network host --name services_container -P -d pdo_services -run_client : build_base build_client +stop_client : - docker rm -f client_container - @ docker run -v $(SCRIPT_DIR)/xfer/:/project/pdo/xfer -it --network host --name client_container pdo_client - # ----------------------------------------------------------------- # We need a repository with the source for the branch we are going # to build. In theory this could just be a copy of the local source @@ -109,14 +118,14 @@ TEST_FILES += -f services_base.yaml TEST_FILES += -f ccf_base.yaml TEST_FILES += -f test.yaml -build_test : repository - PDO_USER_UID=$(PDO_USER_UID) PDO_GROUP_UID=$(PDO_GROUP_UID) \ +build_test : repository build_base build_services_base build_ccf_base + PDO_VERSION=${PDO_VERSION} PDO_USER_UID=$(PDO_USER_UID) PDO_GROUP_UID=$(PDO_GROUP_UID) \ docker-compose $(TEST_FILES) build \ - --build-arg PDO_VERSION=$(shell cd repository; bin/get_version) + --build-arg PDO_VERSION=${PDO_VERSION} -test : clean_config clean_repository build_base build_services_base build_ccf_base build_test - docker-compose $(TEST_FILES) up --abort-on-container-exit - docker-compose $(TEST_FILES) down +test : clean_config clean_repository build_test + PDO_VERSION=${PDO_VERSION} docker-compose $(TEST_FILES) up --abort-on-container-exit + PDO_VERSION=${PDO_VERSION} docker-compose $(TEST_FILES) down # ----------------------------------------------------------------- # Cleaning is a bit interesting because the containers don't go away diff --git a/docker/base.yaml b/docker/base.yaml index 8333d0f0..c4dd5429 100644 --- a/docker/base.yaml +++ b/docker/base.yaml @@ -17,7 +17,10 @@ version: "3.4" services: base_container: - image: pdo_base + image: pdo_base:${PDO_VERSION:-latest} build: context: . dockerfile: pdo_base.dockerfile + args: + ADD_APT_PKGS: ${ADD_APT_PKGS} + PDO_VERSION: ${PDO_VERSION:-latest} diff --git a/docker/ccf_base.yaml b/docker/ccf_base.yaml index a2bedb4c..9202550b 100644 --- a/docker/ccf_base.yaml +++ b/docker/ccf_base.yaml @@ -16,7 +16,7 @@ version: "3.4" services: ccf_container: - image: pdo_ccf + image: pdo_ccf:${PDO_VERSION:-latest} build: context: . dockerfile: pdo_ccf.dockerfile diff --git a/docker/client_base.yaml b/docker/client_base.yaml index 0929529b..a74408fe 100644 --- a/docker/client_base.yaml +++ b/docker/client_base.yaml @@ -16,7 +16,7 @@ version: "3.4" services: client_container: - image: pdo_client + image: pdo_client:${PDO_VERSION:-latest} build: context: . dockerfile: pdo_client.dockerfile diff --git a/docker/pdo_client.dockerfile b/docker/pdo_client.dockerfile index c8bb7f17..bcf44c8b 100644 --- a/docker/pdo_client.dockerfile +++ b/docker/pdo_client.dockerfile @@ -37,6 +37,9 @@ USER $UNAME # ----------------------------------------------------------------- ARG REBUILD 0 +ARG PDO_SOURCE_ROOT=/project/pdo/src +ENV PDO_SOURCE_ROOT=${PDO_SOURCE_ROOT} + ARG PDO_DEBUG_BUILD=0 ENV PDO_DEBUG_BUILD=${PDO_DEBUG_BUILD} @@ -54,7 +57,7 @@ ENV PDO_LOG_LEVEL=${PDO_LOG_LEVEL} # copy the source files into the image WORKDIR /project/pdo -COPY --chown=${UNAME}:${UNAME} repository /project/pdo/src +COPY --chown=${UNAME}:${UNAME} repository ${PDO_SOURCE_ROOT} # copy the tools because we want to be able to # use them even without a mount point after the @@ -66,10 +69,13 @@ COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ RUN /project/pdo/tools/build_client.sh ARG PDO_HOSTNAME -ENV PDO_HOSTNAME=$PDO_HOSTNAME +ENV PDO_HOSTNAME=${PDO_HOSTNAME} ARG PDO_LEDGER_URL -ENV PDO_LEDGER_URL=$PDO_LEDGER_URL +ENV PDO_LEDGER_URL=${PDO_LEDGER_URL} + +ARG PDO_LEDGER_KEY_ROOT=/project/pdo/xfer/ccf/keys/ +ENV PDO_LEDGER_KEY_ROOT=${PDO_LEDGER_KEY_ROOT} # the client is set up for interactive access; the environment can be # set up by source /project/pdo/tools/start_client.sh with the arguments diff --git a/docker/services_base.yaml b/docker/services_base.yaml index 72c619e2..ddf8804f 100644 --- a/docker/services_base.yaml +++ b/docker/services_base.yaml @@ -17,7 +17,7 @@ version: "3.4" services: services_container: - image: pdo_services + image: pdo_services:${PDO_VERSION:-latest} build: context: . dockerfile: pdo_services.dockerfile