From 59f2eed87b2cd0ca34d315d44c40b145ebbbe513 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Mon, 17 Feb 2025 13:25:34 +0200 Subject: [PATCH] Improve docker build script - option to build single service and custom tag (#2284) Signed-off-by: Avgustin Marinov --- docker/docker_build/build_all_dev.sh | 46 --------------------- docker/docker_build/build_dev.sh | 60 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 46 deletions(-) delete mode 100755 docker/docker_build/build_all_dev.sh create mode 100755 docker/docker_build/build_dev.sh diff --git a/docker/docker_build/build_all_dev.sh b/docker/docker_build/build_all_dev.sh deleted file mode 100755 index 719acd29e..000000000 --- a/docker/docker_build/build_all_dev.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2023 Bosch.IO GmbH and others -# -# This program and the accompanying materials are made -# available under the terms of the Eclipse Public License 2.0 -# which is available at https://www.eclipse.org/legal/epl-2.0/ -# -# SPDX-License-Identifier: EPL-2.0 -# -set -xe - -# Usage: builds all docker images. Use: -# -v to pass version -# -f to pass flavour. "mysql" stands for MySQL while all the rest (and default) is assumed Standard -# -r the local maven repository the already built application jars are located into - -VERSION=0-SNAPSHOT -MVN_REPO=~/.m2/repository - -while getopts v:f:r: option -do - case "${option}" - in - v)VERSION=${OPTARG};; - r)MVN_REPO=${OPTARG};; - esac -done - -echo "hawkBit version : ${VERSION}" -echo "maven repository : ${MVN_REPO}" - -DOCKER_FILE="Dockerfile_dev" -echo "docker file : ${DOCKER_FILE}" - -function build() { - docker build -t hawkbit/$1:${VERSION} -t hawkbit/$1:latest --build-arg HAWKBIT_APP=$1 --build-arg HAWKBIT_VERSION=${VERSION} -f ${DOCKER_FILE} "${MVN_REPO}" -} - -# micro-services -build "hawkbit-ddi-server" -build "hawkbit-dmf-server" -build "hawkbit-mgmt-server" -build "hawkbit-simple-ui" -# monolith -build "hawkbit-update-server" diff --git a/docker/docker_build/build_dev.sh b/docker/docker_build/build_dev.sh new file mode 100755 index 000000000..6d0d2935f --- /dev/null +++ b/docker/docker_build/build_dev.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Copyright (c) 2023 Bosch.IO GmbH and others +# +# This program and the accompanying materials are made +# available under the terms of the Eclipse Public License 2.0 +# which is available at https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# + +#set -xe + +# Usage: builds all docker images. Use: +# -v to pass version +# -r the local maven repository the already built application jars are located into +# -t the docker tag the build image(s) will be tagged with +# - if not passed all images will be built + +VERSION=0-SNAPSHOT +MVN_REPO=~/.m2/repository +TAG=latest + +while getopts v:r:t: option +do + case "${option}" + in + v)VERSION=${OPTARG};; + r)MVN_REPO=${OPTARG};; + t)TAG=${OPTARG};; + *) echo "Usage: $0 -v -r -t "; exit 1;; + esac +done +# Shift arguments after pots +shift $((OPTIND - 1)) + +echo "hawkBit version : ${VERSION}" +echo "maven repository : ${MVN_REPO}" +echo "docker tag : ${TAG}" + +DOCKER_FILE="Dockerfile_dev" +echo "docker file : ${DOCKER_FILE}" + +function build() { + docker build -t hawkbit/$1:${TAG} --build-arg HAWKBIT_APP=$1 --build-arg HAWKBIT_VERSION=${VERSION} -f ${DOCKER_FILE} "${MVN_REPO}" +} + +if [ -z "$1" ]; then + echo "Build all" + # micro-services + build "hawkbit-ddi-server" + build "hawkbit-dmf-server" + build "hawkbit-mgmt-server" + build "hawkbit-simple-ui" + # monolith + build "hawkbit-update-server" +else + echo "Build $1" + build $1 +fi