You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by yu...@apache.org on 2024/09/21 06:04:57 UTC
(polaris) branch main updated: Add support to build docker image with build args (#227)
This is an automated email from the ASF dual-hosted git repository.
yufei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new a0b24ce Add support to build docker image with build args (#227)
a0b24ce is described below
commit a0b24ce55c95cf102963cb2bcbfea9c023c4368b
Author: MonkeyCanCode <yo...@gmail.com>
AuthorDate: Sat Sep 21 01:04:53 2024 -0500
Add support to build docker image with build args (#227)
---
run.sh | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/run.sh b/run.sh
index ae0a47f..c56e9de 100755
--- a/run.sh
+++ b/run.sh
@@ -21,13 +21,52 @@
# Runs Polaris as a mini-deployment locally. Creates two pods that bind themselves to port 8181.
-# deploy the registry
+# Initialize variables
+BUILD_ARGS="" # Initialize an empty string to store Docker build arguments
+
+# Function to display usage information
+usage() {
+ 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 "b:h" opt; do
+ case ${opt} in
+ 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
+ ;;
+ *)
+ 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
+# 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..."
-docker build -t localhost:5001/polaris -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..."