Move docker creation and deletion to tb.sh

A makefile was used only for creation and clean up of the docker
image for building. In this process, all the environment variables
were sourced and included into the Makefile. However this can fail
on systems that has functions and cause a failing makefile.

Trying to fixing this issue I realize that this Makefile ain't needed,
as all the logic for docker management is under `tb.sh`, therefore makes
sense to remove this Makefile and use this script for the entire process.

Story: 2002560

Change-Id: I2795593521a5d16dc2033861946fd09c2270424e
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
This commit is contained in:
Erich Cordoba 2019-02-19 10:14:25 -06:00
parent c8e0636ad2
commit 12ca05299d
3 changed files with 26 additions and 48 deletions

View File

@ -1,44 +0,0 @@
# TC Build container
# Set defaults that may be overridden in the buidrc
MY_TC_RELEASE := tis-r5-pike
UID := $(shell id -u)
USER := $(shell id -un)
# Import the build config
NULL := $(shell bash -c "source buildrc; set | sed -E '/^[[:alnum:]_]+/s/=/:=/' | sed 's/^//' > .makeenv")
include .makeenv
MYUNAME ?= $(USER)
TC_CONTAINER_NAME := $(MYUNAME)-centos-builder
TC_CONTAINER_TAG := local/$(MYUNAME)-stx-builder:7.4
TC_DOCKERFILE := Dockerfile
all:
docker build \
--build-arg MYUID=$(UID) \
--build-arg MYUNAME=$(MYUNAME) \
--ulimit core=0 \
--network host \
-t $(TC_CONTAINER_TAG) \
-f $(TC_DOCKERFILE) \
.
clean:
docker rm $(TC_CONTAINER_NAME) || true
docker image rm $(TC_CONTAINER_TAG)
env:
@echo "TC_DOCKERFILE=$(TC_DOCKERFILE)"
@echo "TC_CONTAINER_NAME=$(TC_CONTAINER_NAME)"
@echo "TC_CONTAINER_TAG=$(TC_CONTAINER_TAG)"
@echo "SOURCE_REMOTE_NAME=$(SOURCE_REMOTE_NAME)"
@echo "SOURCE_REMOTE_URI=$(SOURCE_REMOTE_URI)"
@echo "HOST_MIRROR_DIR=$(HOST_MIRROR_DIR)"
@echo "MY_TC_RELEASE=$(MY_TC_RELEASE)"
@echo "LOCALDISK=${LOCALDISK}"
@echo "GUEST_LOCALDISK=${GUEST_LOCALDISK}"
.PHONY: all clean env

View File

@ -54,11 +54,11 @@ Build image
~~~~~~~~~~~
Once the configuration files have been customized, it is possible to build
the docker image. This process is automated by the Makefile.
the docker image. This process is automated by the ``tb.sh`` script.
.. code-block:: bash
make
./tb.sh create
NOTE:
~~~~~

26
tb.sh
View File

@ -25,6 +25,17 @@ TC_CONTAINER_NAME=${MYUNAME}-centos-builder
TC_CONTAINER_TAG=local/${MYUNAME}-stx-builder:7.4
TC_DOCKERFILE=Dockerfile
function create_container {
docker build \
--build-arg MYUID=$(id -u) \
--build-arg MYUNAME=${USER} \
--ulimit core=0 \
--network host \
-t ${TC_CONTAINER_TAG} \
-f ${TC_DOCKERFILE} \
.
}
function exec_container {
docker cp ${WORK_DIR}/buildrc ${TC_CONTAINER_NAME}:/home/${MYUNAME}
docker cp ${WORK_DIR}/localrc ${TC_CONTAINER_NAME}:/home/${MYUNAME}
@ -57,8 +68,13 @@ function kill_container {
docker kill ${TC_CONTAINER_NAME}
}
function clean_container {
docker rm ${TC_CONTAINER_NAME} || true
docker image rm ${TC_CONTAINER_TAG}
}
function usage {
echo "$0 [run|exec|env|stop|kill]"
echo "$0 [create|run|exec|env|stop|kill|clean]"
}
case $CMD in
@ -74,6 +90,9 @@ case $CMD in
echo "MY_TC_RELEASE=${MY_TC_RELEASE}"
echo "MY_REPO_ROOT_DIR=${MY_REPO_ROOT_DIR}"
;;
create)
create_container
;;
exec)
exec_container
;;
@ -86,9 +105,12 @@ case $CMD in
kill)
kill_container
;;
clean)
clean_container
;;
*)
echo "Unknown command: $CMD"
usage
usage
exit 1
;;
esac