Skip to content

Commit

Permalink
Some minor docker improvements
Browse files Browse the repository at this point in the history
Signed-off-by: g2flyer <michael.steiner@intel.com>
  • Loading branch information
g2flyer committed Jan 16, 2024
1 parent e62be5e commit ece73fa
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
45 changes: 27 additions & 18 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion docker/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
2 changes: 1 addition & 1 deletion docker/ccf_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/client_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions docker/pdo_client.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/services_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ece73fa

Please sign in to comment.