From b7784e2e7ba7a55d108235799b88bfdfff39a0f3 Mon Sep 17 00:00:00 2001 From: Yong Zheng Date: Wed, 28 Aug 2024 21:22:09 -0500 Subject: [PATCH 1/3] Add support to build docker image with eclipselink --- run.sh | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/run.sh b/run.sh index eb9e4d5e5b..6cc294267d 100755 --- a/run.sh +++ b/run.sh @@ -21,20 +21,51 @@ # Runs Polaris as a mini-deployment locally. Creates two pods that bind themselves to port 8181. -CURRENT_DIR=$(pwd) +# Initialize variables +ECLIPSELINK="false" # Default value -# deploy the registry +# Function to display usage information +usage() { + echo "Usage: $0 [-e true|false] [-h]" + echo " -e Set the ECLIPSELINK flag (default: false)" + echo " -h Display this help message" + exit 1 +} + +# Parse command-line arguments +while getopts "e:h" opt; do + case ${opt} in + e) + ECLIPSELINK=${OPTARG} + if [[ "$ECLIPSELINK" != "true" && "$ECLIPSELINK" != "false" ]]; then + echo "Error: Invalid value for -e. Use 'true' or 'false'." + usage + fi + ;; + h) + usage + ;; + *) + usage + ;; + esac +done + +# Shift off the options and arguments +shift $((OPTIND-1)) + +# Deploy the registry echo "Building Kind Registry..." sh ./kind-registry.sh -# build and deploy the server image -echo "Building polaris image..." -docker build -t localhost:5001/polaris -f Dockerfile . +# Build and deploy the server image +echo "Building polaris image with ECLIPSELINK=$ECLIPSELINK..." +docker build -t localhost:5001/polaris --build-arg ECLIPSELINK=$ECLIPSELINK -f Dockerfile . echo "Pushing polaris image..." docker push localhost:5001/polaris echo "Loading polaris image to kind..." kind load docker-image localhost:5001/polaris:latest -echo "Applying kubernetes manifests..." +echo "Applying Kubernetes manifests..." kubectl delete -f k8/deployment.yaml --ignore-not-found kubectl apply -f k8/deployment.yaml From f5c6b51b397cc4bdd8c56cc0ee28435a398e191b Mon Sep 17 00:00:00 2001 From: Yong Zheng Date: Thu, 29 Aug 2024 14:25:06 -0500 Subject: [PATCH 2/3] add suppor for arbitrary args --- run.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/run.sh b/run.sh index 6cc294267d..7a3a7d2fe7 100755 --- a/run.sh +++ b/run.sh @@ -22,25 +22,24 @@ # Runs Polaris as a mini-deployment locally. Creates two pods that bind themselves to port 8181. # Initialize variables -ECLIPSELINK="false" # Default value +BUILD_ARGS="" # Initialize an empty string to store Docker build arguments # Function to display usage information usage() { - echo "Usage: $0 [-e true|false] [-h]" - echo " -e Set the ECLIPSELINK flag (default: false)" + echo "Usage: $0 [-b build-arg1=value1,build-arg2=value2,...] [-h]" + echo " -b Pass a set of arbitrary build arguments to docker build, separated by commas" echo " -h Display this help message" exit 1 } # Parse command-line arguments -while getopts "e:h" opt; do +while getopts "b:h" opt; do case ${opt} in - e) - ECLIPSELINK=${OPTARG} - if [[ "$ECLIPSELINK" != "true" && "$ECLIPSELINK" != "false" ]]; then - echo "Error: Invalid value for -e. Use 'true' or 'false'." - usage - fi + b) + IFS=',' read -ra ARGS <<< "${OPTARG}" # Split the comma-separated list into an array + for arg in "${ARGS[@]}"; do + BUILD_ARGS+=" --build-arg ${arg}" # Append each build argument to the list + done ;; h) usage @@ -58,14 +57,21 @@ shift $((OPTIND-1)) echo "Building Kind Registry..." sh ./kind-registry.sh +# Check if BUILD_ARGS is not empty and print the build arguments +if [[ -n "$BUILD_ARGS" ]]; then + echo "Building polaris image with build arguments:$BUILD_ARGS" +else + echo "Building polaris image without any additional build arguments." +fi + # Build and deploy the server image -echo "Building polaris image with ECLIPSELINK=$ECLIPSELINK..." -docker build -t localhost:5001/polaris --build-arg ECLIPSELINK=$ECLIPSELINK -f Dockerfile . +docker build -t localhost:5001/polaris $BUILD_ARGS -f Dockerfile . echo "Pushing polaris image..." docker push localhost:5001/polaris echo "Loading polaris image to kind..." kind load docker-image localhost:5001/polaris:latest +# Apply Kubernetes deployment echo "Applying Kubernetes manifests..." kubectl delete -f k8/deployment.yaml --ignore-not-found kubectl apply -f k8/deployment.yaml From 162f53e6e6966e77e9dccd5f57f9adeb77a5b5d8 Mon Sep 17 00:00:00 2001 From: Yong Zheng Date: Wed, 4 Sep 2024 20:50:23 -0500 Subject: [PATCH 3/3] Fix nit --- run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 1106b2153a..c56e9de02f 100755 --- a/run.sh +++ b/run.sh @@ -59,7 +59,7 @@ sh ./kind-registry.sh # Check if BUILD_ARGS is not empty and print the build arguments if [[ -n "$BUILD_ARGS" ]]; then - echo "Building polaris image with build arguments:$BUILD_ARGS" + echo "Building polaris image with build arguments: $BUILD_ARGS" else echo "Building polaris image without any additional build arguments." fi @@ -74,4 +74,4 @@ kind load docker-image localhost:5001/polaris:latest echo "Applying kubernetes manifests..." kubectl delete -f k8/deployment.yaml --ignore-not-found -kubectl apply -f k8/deployment.yaml \ No newline at end of file +kubectl apply -f k8/deployment.yaml