mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-14 00:04:59 -05:00
[docker] added arguments '--log' and '--no-tags' to docker.build.sh script
This commit is contained in:
parent
cd5fabf53e
commit
3347646178
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
MSG="";
|
MSG="";
|
||||||
PRUNE="false";
|
PRUNE="false";
|
||||||
|
OVERRIDE_TAGS="false";
|
||||||
LOG_FILE=""
|
ENABLE_LOG="false";
|
||||||
#LOG_FILE="$(dirname -- "$( readlink -f -- "$0"; )")/build.log";
|
LOG_FILE="$(dirname -- "$( readlink -f -- "$0"; )")/build.log";
|
||||||
|
|
||||||
function appendOutput()
|
function appendOutput()
|
||||||
{
|
{
|
||||||
@ -12,23 +12,31 @@ function appendOutput()
|
|||||||
|
|
||||||
ARGS=$@;
|
ARGS=$@;
|
||||||
LINE="${ARGS}\n";
|
LINE="${ARGS}\n";
|
||||||
if [ -z "${LOG_FILE}" ]; then echo -e "${LINE}" > /dev/tty; else echo -e "${LINE}" &>> "${LOG_FILE}"; fi
|
if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then echo -e "${LINE}" > /dev/tty; else echo -e "${LINE}" 2>&1 | tee -a ${LOG_FILE}; fi
|
||||||
|
|
||||||
MSG="${MSG}${LINE}";
|
MSG="${MSG}${LINE}";
|
||||||
}
|
}
|
||||||
|
|
||||||
function runDockerBuild()
|
function runDockerBuild()
|
||||||
{
|
{
|
||||||
if [ "${PRUNE}" == "true" ]; then docker system prune -a -f; fi
|
if [ "${PRUNE}" == "true" ]; then
|
||||||
|
if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then docker system prune -a -f;
|
||||||
|
else docker system prune -a -f | tee -a ${LOG_FILE}; fi
|
||||||
|
fi
|
||||||
|
|
||||||
STARTTS=$(date +%s);
|
STARTTS=$(date +%s);
|
||||||
ARGS=$@;
|
ARGS=$@;
|
||||||
|
|
||||||
APP_VERSION=$(grep -o '"version":\s*"[^"]*"' ./package.json | cut -f4- -d\" | tr -d '"')
|
APP_VERSION=$(grep -o '"version":\s*"[^"]*"' ./package.json | cut -f4- -d\" | tr -d '"');
|
||||||
BUILD_CMD="docker build -f docker/Dockerfile --force-rm --no-cache ${ARGS} -t meshcentral:latest -t meshcentral:${APP_VERSION} .";
|
BASE_TAGS="";
|
||||||
|
if [ -z "${OVERRIDE_TAGS}" ] || [ "${OVERRIDE_TAGS}" != "true" ]; then
|
||||||
|
BASE_TAGS="-t meshcentral:latest -t meshcentral:${APP_VERSION}";
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_CMD="docker build -f docker/Dockerfile --force-rm --no-cache ${ARGS} ${BASE_TAGS} .";
|
||||||
appendOutput "Current build: ${BUILD_CMD}";
|
appendOutput "Current build: ${BUILD_CMD}";
|
||||||
|
|
||||||
if [ -z "${LOG_FILE}" ]; then ${BUILD_CMD}; else ${BUILD_CMD} &>> "${LOG_FILE}"; fi
|
if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then ${BUILD_CMD}; else ${BUILD_CMD} | tee -a ${LOG_FILE}; fi
|
||||||
if [ $? -ne 0 ]; then exit $?; fi
|
if [ $? -ne 0 ]; then exit $?; fi
|
||||||
|
|
||||||
IMAGEID=$(docker images --format "{{.ID}} {{.CreatedAt}}" | sort -rk 2 | awk 'NR==1{print $1}');
|
IMAGEID=$(docker images --format "{{.ID}} {{.CreatedAt}}" | sort -rk 2 | awk 'NR==1{print $1}');
|
||||||
@ -69,6 +77,14 @@ if ! [ -z $1 ]; then
|
|||||||
PRUNE="true";
|
PRUNE="true";
|
||||||
shift 1;
|
shift 1;
|
||||||
;;
|
;;
|
||||||
|
--log)
|
||||||
|
ENABLE_LOG="true";
|
||||||
|
shift 1;
|
||||||
|
;;
|
||||||
|
--no-tags)
|
||||||
|
OVERRIDE_TAGS="true";
|
||||||
|
shift 1;
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break;
|
break;
|
||||||
;;
|
;;
|
||||||
@ -89,6 +105,6 @@ runDockerBuild ${MAINARGS};
|
|||||||
#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes ${MAINARGS};
|
#runDockerBuild --build-arg INCLUDE_MONGODBTOOLS=yes ${MAINARGS};
|
||||||
|
|
||||||
echo "";
|
echo "";
|
||||||
echo -e "${MSG}";
|
if [ -z "${ENABLE_LOG}" ] || [ "${ENABLE_LOG}" != "true" ]; then echo -e "${MSG}"; else echo -e "${MSG}" 2>&1 | tee -a ${LOG_FILE}; fi
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user