X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=https-server%2Fbuild.sh;h=8647a0b6f986b0e94f0712479fcce41b7cd69d93;hb=bf779f6b82c5d7f7cc4cd6f5d01c347c51b45e51;hp=c7aabac8ad1dada76c211b9da5052a7f9bd559ed;hpb=c5655db5780275b07b25b57b767808f2f1eac7d9;p=nonrtric%2Fplt%2Franpm.git diff --git a/https-server/build.sh b/https-server/build.sh index c7aabac..8647a0b 100755 --- a/https-server/build.sh +++ b/https-server/build.sh @@ -18,14 +18,14 @@ # # Build image from Dockerfile with/without custom image tag -# Optionally push to external docker hub repo +# Optionally push to external image repo print_usage() { echo "Usage: build.sh no-push| []" exit 1 } -if [ $# -ne 1 ] && [ $# -ne 2 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then print_usage fi @@ -39,14 +39,39 @@ else echo "Attempt to push built image to: "$REPO fi -if [ "$2" != "" ]; then - IMAGE_TAG=$2 -fi - echo "Setting image tag to: "$IMAGE_TAG +shift +while [ $# -ne 0 ]; do + if [ $1 == "--tag" ]; then + shift + if [ -z "$1" ]; then + print_usage + fi + IMAGE_TAG=$1 + echo "Setting image tag to: "$IMAGE_TAG + shift + else + echo "Unknown parameter: $1" + print_usage + fi +done + +./gen-cert.sh + +echo "" +echo "Certs generated" IMAGE=$IMAGE_NAME:$IMAGE_TAG -echo "Building image $IMAGE" + +export DOCKER_DEFAULT_PLATFORM=linux/amd64 +CURRENT_PLATFORM=$(docker system info --format '{{.OSType}}/{{.Architecture}}') +if [ $CURRENT_PLATFORM != $DOCKER_DEFAULT_PLATFORM ]; then + echo "Image may not work on the current platform: $CURRENT_PLATFORM, only platform $DOCKER_DEFAULT_PLATFORM supported" +fi + +echo "Building image: $IMAGE with architecture: $DOCKER_DEFAULT_PLATFORM" + docker build -t $IMAGE_NAME:$IMAGE_TAG . + if [ $? -ne 0 ]; then echo "BUILD FAILED" exit 1