This is an automated email from the ASF dual-hosted git repository.

chenli pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 4861ffe1a6 feat: enable image-related script to accept command line 
args (#4036)
4861ffe1a6 is described below

commit 4861ffe1a6db3149e085dbdce19951d906ea6cfd
Author: Jiadong Bai <[email protected]>
AuthorDate: Tue Nov 18 22:11:29 2025 -0800

    feat: enable image-related script to accept command line args (#4036)
    
    <!--
    Thanks for sending a pull request (PR)! Here are some tips for you:
    1. If this is your first time, please read our contributor guidelines:
    [Contributing to
    Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
      2. Ensure you have added or run the appropriate tests for your PR
      3. If the PR is work in progress, mark it a draft on GitHub.
      4. Please write your PR title to summarize what this PR proposes, we
        are following Conventional Commits style for PR titles as well.
      5. Be sure to keep the PR description updated to reflect all changes.
    -->
    
    ### What changes were proposed in this PR?
    <!--
    Please clarify what changes you are proposing. The purpose of this
    section
    is to outline the changes. Here are some tips for you:
      1. If you propose a new API, clarify the use case for a new API.
      2. If you fix a bug, you can clarify why it is a bug.
      3. If it is a refactoring, clarify what has been changed.
      3. It would be helpful to include a before-and-after comparison using
         screenshots or GIFs.
      4. Please consider writing useful notes for better and faster reviews.
    -->
    This PR improves two shell scripts: `build-images.sh` and
    `merge-image-tags` by enabling them to accept command line args. This
    can be useful when later we introduce the CI to automate the image
    building
    
    ### Any related issues, documentation, discussions?
    <!--
    Please use this section to link other resources if not mentioned
    already.
    1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves
    #1234`
    or `Closes #1234`. If it is only related, simply mention the issue
    number.
      2. If there is design documentation, please add the link.
      3. If there is a discussion in the mailing list, please add the link.
    -->
    No. This is a small improvement so I think there is no need to raise an
    issue
    
    ### How was this PR tested?
    <!--
    If tests were added, say they were added here. Or simply mention that if
    the PR
    is tested with existing test cases. Make sure to include/update test
    cases that
    check the changes thoroughly including negative and positive cases if
    possible.
    If it was tested in a way different from regular unit tests, please
    clarify how
    you tested step by step, ideally copy and paste-able, so that other
    reviewers can
    test and check, and descendants can verify in the future. If tests were
    not added,
    please describe why they were not added and/or why it was difficult to
    add.
    -->
    By executing the scripts with different args.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    <!--
    If generative AI tooling has been used in the process of authoring this
    PR,
    please include the phrase: 'Generated-by: ' followed by the name of the
    tool
    and its version. If no, write 'No'.
    Please refer to the [ASF Generative Tooling
    Guidance](https://www.apache.org/legal/generative-tooling.html) for
    details.
    -->
    No
    
    Co-authored-by: Chen Li <[email protected]>
---
 bin/build-images.sh     | 91 +++++++++++++++++++++++++++++++++++++++----------
 bin/merge-image-tags.sh | 20 ++++++-----
 2 files changed, 85 insertions(+), 26 deletions(-)

diff --git a/bin/build-images.sh b/bin/build-images.sh
index 3ea069afc6..8c55656db9 100755
--- a/bin/build-images.sh
+++ b/bin/build-images.sh
@@ -15,19 +15,62 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
-
 set -e
 
-# Prompt for base tag
+# Default values
 DEFAULT_TAG="latest"
-read -p "Enter the base tag for the images [${DEFAULT_TAG}]: " BASE_TAG
-BASE_TAG=${BASE_TAG:-$DEFAULT_TAG}
-
-# Prompt for which services to build
 DEFAULT_SERVICES="*"
-read -p "Enter services to build (comma-separated, '*' for all) 
[${DEFAULT_SERVICES}]: " SERVICES_INPUT
-SERVICES_INPUT=${SERVICES_INPUT:-$DEFAULT_SERVICES}
+WITH_R_SUPPORT="false"
+
+# Parse command-line arguments
+while [[ $# -gt 0 ]]; do
+  case $1 in
+    --tag|-t)
+      BASE_TAG="$2"
+      shift 2
+      ;;
+    --services|-s)
+      SERVICES_INPUT="$2"
+      shift 2
+      ;;
+    --with-r-support)
+      WITH_R_SUPPORT="true"
+      shift
+      ;;
+    --help|-h)
+      echo "Usage: $0 [OPTIONS]"
+      echo ""
+      echo "Options:"
+      echo "  -t, --tag TAG              Base tag for the images (default: 
latest)"
+      echo "  -s, --services SERVICES    Services to build, comma-separated or 
'*' for all (default: *)"
+      echo "  --with-r-support           Enable R support for 
computing-unit-master (sets WITH_R_SUPPORT=true)"
+      echo "  -h, --help                 Show this help message"
+      echo ""
+      echo "Examples:"
+      echo "  $0 --tag v1.0.0 --services '*' --with-r-support"
+      echo "  $0 -t latest -s 'gui,computing-unit-master'"
+      echo "  $0  # Interactive mode"
+      exit 0
+      ;;
+    *)
+      echo "❌ Unknown option: $1"
+      echo "Run '$0 --help' for usage information."
+      exit 1
+      ;;
+  esac
+done
+
+# If BASE_TAG not provided via command-line, prompt interactively
+if [[ -z "$BASE_TAG" ]]; then
+  read -p "Enter the base tag for the images [${DEFAULT_TAG}]: " BASE_TAG
+  BASE_TAG=${BASE_TAG:-$DEFAULT_TAG}
+fi
+
+# If SERVICES_INPUT not provided via command-line, prompt interactively
+if [[ -z "$SERVICES_INPUT" ]]; then
+  read -p "Enter services to build (comma-separated, '*' for all) 
[${DEFAULT_SERVICES}]: " SERVICES_INPUT
+  SERVICES_INPUT=${SERVICES_INPUT:-$DEFAULT_SERVICES}
+fi
 
 # Convert the user input into an array for easy lookup
 IFS=',' read -ra SELECTED_SERVICES <<< "$SERVICES_INPUT"
@@ -64,6 +107,9 @@ fi
 
 FULL_TAG="${BASE_TAG}-${TAG_SUFFIX}"
 echo "🔍 Detected architecture: $ARCH -> Building for $PLATFORM with tag 
:$FULL_TAG"
+if [[ "$WITH_R_SUPPORT" == "true" ]]; then
+  echo "🔍 R support enabled for computing-unit-master"
+fi
 
 # Ensure Buildx is ready
 docker buildx create --name texera-builder --use --bootstrap > /dev/null 2>&1 
|| docker buildx use texera-builder
@@ -72,7 +118,6 @@ cd "$(dirname "$0")"
 
 # Auto-detect Dockerfiles in current directory
 dockerfiles=( *.dockerfile )
-
 if [[ ${#dockerfiles[@]} -eq 0 ]]; then
   echo "❌ No Dockerfiles found (*.dockerfile) in the current directory."
   exit 1
@@ -90,15 +135,25 @@ for dockerfile in "${dockerfiles[@]}"; do
   fi
 
   image="texera/$service_name:$FULL_TAG"
-
   echo "👉 Building $image from $dockerfile"
 
-  docker buildx build \
-    --platform "$PLATFORM" \
-    -f "$dockerfile" \
-    -t "$image" \
-    --push \
-    ..
+  # Add WITH_R_SUPPORT build arg for computing-unit-master
+  if [[ "$service_name" == "computing-unit-master" && "$WITH_R_SUPPORT" == 
"true" ]]; then
+    docker buildx build \
+      --platform "$PLATFORM" \
+      -f "$dockerfile" \
+      -t "$image" \
+      --build-arg WITH_R_SUPPORT=true \
+      --push \
+      ..
+  else
+    docker buildx build \
+      --platform "$PLATFORM" \
+      -f "$dockerfile" \
+      -t "$image" \
+      --push \
+      ..
+  fi
 done
 
 # Build pylsp service (directory: pylsp)
@@ -125,4 +180,4 @@ if should_build "y-websocket-server"; then
     ./y-websocket-server
 fi
 
-echo "✅ All images built and pushed with tag :$FULL_TAG"
+echo "✅ All images built and pushed with tag :$FULL_TAG"
\ No newline at end of file
diff --git a/bin/merge-image-tags.sh b/bin/merge-image-tags.sh
index ab44b2297f..2458256d76 100755
--- a/bin/merge-image-tags.sh
+++ b/bin/merge-image-tags.sh
@@ -16,18 +16,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
-
 set -e
 
-# Prompt for base tag
+# Accept parameters from command line
 DEFAULT_TAG="latest"
-read -p "Enter the base tag to merge [${DEFAULT_TAG}]: " BASE_TAG
-BASE_TAG=${BASE_TAG:-$DEFAULT_TAG}
-
-# Prompt for which services' manifests to merge
 DEFAULT_SERVICES="*"
-read -p "Enter services to merge (comma-separated, '*' for all) 
[${DEFAULT_SERVICES}]: " SERVICES_INPUT
-SERVICES_INPUT=${SERVICES_INPUT:-$DEFAULT_SERVICES}
+
+BASE_TAG="${1:-$DEFAULT_TAG}"
+SERVICES_INPUT="${2:-$DEFAULT_SERVICES}"
+
+echo "Using base tag: $BASE_TAG"
+echo "Services to merge: $SERVICES_INPUT"
 
 # Convert input into array for lookup
 IFS=',' read -ra SELECTED_SERVICES <<< "$SERVICES_INPUT"
@@ -82,3 +81,8 @@ for svc in "${services[@]}"; do
 
   echo "✅ Created manifest: texera/$svc:$BASE_TAG"
 done
+
+echo ""
+echo "=========================================="
+echo "✅ All manifests merged successfully!"
+echo "=========================================="
\ No newline at end of file

Reply via email to