X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pm-file-converter%2Fbuild.sh;h=4803020e0181ace4370dc281890acf4a4b172d71;hb=6bf63a18d595d40ed169e79e681fc526a400aa40;hp=69bcc9a0043954aa91be56d55a4871f823aebd46;hpb=5a01ec4da9c004c8b74d2997ee7d3ffa77dfaf95;p=nonrtric%2Fplt%2Franpm.git diff --git a/pm-file-converter/build.sh b/pm-file-converter/build.sh index 69bcc9a..4803020 100755 --- a/pm-file-converter/build.sh +++ b/pm-file-converter/build.sh @@ -18,18 +18,18 @@ # #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|bm| []" + echo "Usage: build.sh no-push| [--tag ]" exit 1 } -if [ $# -ne 1 ] && [ $# -ne 2 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then print_usage fi -IMAGE_NAME="kafka-pm-producer" +IMAGE_NAME="pm-file-converter" IMAGE_TAG="latest" REPO="" if [ $1 == "no-push" ]; then @@ -38,15 +38,38 @@ else REPO=$1 echo "Attempt to push built image to: "$REPO fi +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 -if [ "$2" != "" ]; then - IMAGE_TAG=$2 -fi - echo "Setting image tag to: "$IMAGE_TAG +./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