You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2024/08/19 17:44:37 UTC

(spark-kubernetes-operator) branch main updated: [SPARK-49299] Add `buildDockerImage` Gradle Task

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

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 798b297  [SPARK-49299] Add `buildDockerImage` Gradle Task
798b297 is described below

commit 798b297ac530e404e97e0330ada6fa3e02c5cacd
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Mon Aug 19 10:44:31 2024 -0700

    [SPARK-49299] Add `buildDockerImage` Gradle Task
    
    ### What changes were proposed in this pull request?
    
    This PR aims to add `buildDockerImage` Gradle Task and update `README.md` and `GitHub Action CIs` accordingly.
    
    ### Why are the changes needed?
    
    To provide an easy way to build the image without knowing the current version number.
    
    **BEFORE**
    ```
    $ docker build --build-arg APP_VERSION=0.1.0 -t spark-kubernetes-operator:0.1.0 -f build-tools/docker/Dockerfile .
    ```
    
    **AFTER**
    ```
    ./gradlew buildDockerImage
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, this is a dev-only change.
    
    ### How was this patch tested?
    
    Pass the CIs with the newly updated CIs.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #68 from dongjoon-hyun/SPARK-49299.
    
    Authored-by: Dongjoon Hyun <do...@apache.org>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 .github/workflows/build_and_test.yml | 10 ++++++++--
 README.md                            |  2 +-
 build.gradle                         |  6 ++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml
index 7104993..7ec3348 100644
--- a/.github/workflows/build_and_test.yml
+++ b/.github/workflows/build_and_test.yml
@@ -50,9 +50,15 @@ jobs:
     steps:
       - name: Checkout repository
         uses: actions/checkout@v4
+      - name: Set up JDK 17
+        uses: actions/setup-java@v4
+        with:
+          java-version: 17
+          distribution: 'adopt'
+          cache: 'gradle'
       - name: Build Operator Image
         run: |
-          docker build --build-arg APP_VERSION=0.1.0 -t spark-kubernetes-operator:0.1.0 -f build-tools/docker/Dockerfile .
+          ./gradlew buildDockerImage
           docker run spark-kubernetes-operator:0.1.0
   k8s-integration-tests:
     name: "K8s Integration Tests"
@@ -82,7 +88,7 @@ jobs:
         run: |
           kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts || true
           eval $(minikube docker-env)
-          docker build --build-arg APP_VERSION=0.1.0 -t spark-kubernetes-operator:0.1.0 -f build-tools/docker/Dockerfile .
+          ./gradlew buildDockerImage
           kubectl run spark-kubernetes-operator --image=spark-kubernetes-operator:0.1.0 --restart=Never
           sleep 5
           kubectl get pods -A
diff --git a/README.md b/README.md
index 616225e..9ca624d 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ $ ./gradlew build
 ## Build Docker Image
 
 ```bash
-$ docker build --build-arg APP_VERSION=0.1.0 -t spark-kubernetes-operator:0.1.0 -f build-tools/docker/Dockerfile  .
+$ ./gradlew buildDockerImage
 ```
 
 ## Install Helm Chart
diff --git a/build.gradle b/build.gradle
index f625dd1..51cb258 100644
--- a/build.gradle
+++ b/build.gradle
@@ -37,6 +37,12 @@ allprojects {
   version = "0.1.0"
 }
 
+tasks.register('buildDockerImage', Exec) {
+  String cmd = "docker build --build-arg APP_VERSION=${version} -t spark-kubernetes-operator:${version} -f build-tools/docker/Dockerfile ."
+  println "Build Docker Image: $cmd"
+  commandLine "sh", "-c", "$cmd"
+}
+
 subprojects {
   apply plugin: 'idea'
   apply plugin: 'eclipse'


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org