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

ricardozanini pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git


The following commit(s) were added to refs/heads/main by this push:
     new fb3e43e8 [KOGITO-9729] - (fix) Preserve directory structure while 
copying files in builder image (#1711)
fb3e43e8 is described below

commit fb3e43e8c462e783a2ada8ba5f4285faf6a79bc2
Author: Ricardo Zanini <[email protected]>
AuthorDate: Fri Dec 1 11:54:09 2023 -0300

    [KOGITO-9729] - (fix) Preserve directory structure while copying files in 
builder image (#1711)
    
    Signed-off-by: Ricardo Zanini <[email protected]>
---
 .../kogito-swf/common/scripts/added/build-app.sh   | 14 +++++++----
 .../tests/bats/kogito-swf-builder-build-app.bats   | 27 ++++++++++++++++++++++
 .../resources/greet-with-inputschema/Dockerfile    |  2 +-
 .../kogito-swf-builder/resources/greet/Dockerfile  |  2 +-
 4 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/modules/kogito-swf/common/scripts/added/build-app.sh 
b/modules/kogito-swf/common/scripts/added/build-app.sh
index 762c791e..2f661aed 100755
--- a/modules/kogito-swf/common/scripts/added/build-app.sh
+++ b/modules/kogito-swf/common/scripts/added/build-app.sh
@@ -3,7 +3,7 @@ set -e
 
 script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
 resources_path="$1"
-if [ ! -z "${resources_path}" ]; then
+if [ -n "${resources_path}" ]; then
     resources_path="$(realpath "${resources_path}")"
 fi
 
@@ -13,15 +13,17 @@ if [ "${SCRIPT_DEBUG}" = "true" ] ; then
     set -x
     export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" 
     log_info "Script debugging is enabled, allowing bash commands and their 
arguments to be printed as they are executed"
+    log_info "Resources path is ${resources_path}"
     printenv
 fi
 
 # Copy resources if exists
-SUPPORTED_FILES=(".yaml" ".yml" ".json" ".properties" ".mvn/jvm.config")
 log_info "-> Copying files from ${resources_path}, if any..."
-if [ ! -z "${resources_path}" ]; then
-    cd "${resources_path}" && find . -regex 
'.*\.\(yaml\|yml\|json\|properties\)$' | sed 's|^./||' | xargs cp -v --parents 
-t "${swf_home_dir}"/src/main/resources/ && cd -
-    find "${resources_path}" -name 'jvm.config' -exec echo "--> found {}" \; 
-exec mkdir -p .mvn \; -exec cp -v {} .mvn/ \;
+if [ -n "${resources_path}" ]; then
+    
destination="${KOGITO_HOME}/serverless-workflow-project/src/main/resources/"
+    log_info "-> Destination folder is ${destination}"
+    cp -vR ${resources_path}/* ${destination}
+    find "${resources_path}" -name 'jvm.config' -exec echo "--> found {}" \; 
-exec mkdir -p  ${destination}/.mvn \; -exec cp -v {} ${destination}/.mvn/ \;
 else
     log_warning "-> Nothing to copy from ${resources_path}"
 fi
@@ -33,6 +35,8 @@ if [ ! -z "${QUARKUS_EXTENSIONS}" ]; then
     ${script_dir_path}/add-extension.sh "${QUARKUS_EXTENSIONS}" "true"
 fi
 
+cd ${KOGITO_HOME}/serverless-workflow-project
+
 "${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \
     -nsu \
     -s "${MAVEN_SETTINGS_PATH}" \
diff --git 
a/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats
 
b/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats
new file mode 100644
index 00000000..d0993822
--- /dev/null
+++ 
b/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats
@@ -0,0 +1,27 @@
+#!/usr/bin/env bats
+
+setup() {
+    export KOGITO_HOME=/tmp/kogito
+    export HOME="${KOGITO_HOME}"
+    mkdir -p "${KOGITO_HOME}"/launch
+    mkdir -p "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/
+    cp $BATS_TEST_DIRNAME/../../../../../kogito-logging/added/logging.sh 
"${KOGITO_HOME}"/launch/
+    cp $BATS_TEST_DIRNAME/../../added/jvm-settings.sh "${KOGITO_HOME}"/launch/
+    cp $BATS_TEST_DIRNAME/../../added/build-app.sh "${KOGITO_HOME}"/launch/
+}
+
+teardown() {
+    rm -rf "${KOGITO_HOME}"
+    rm -rf /tmp/resources
+}
+
+@test "verify copy resources is working" {
+    TEMPD=$(mktemp -d)
+    cp -r 
$BATS_TEST_DIRNAME/../../../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/*
 ${TEMPD}
+
+    # We don't care about the errors to try to execute and build the program, 
just the copy matters
+    source ${KOGITO_HOME}/launch/build-app.sh ${TEMPD} || true
+    
+    [[ -f 
"${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/greet.sw.json ]]
+    [[ -f 
"${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/schemas/input.json
 ]]
+}
diff --git 
a/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile 
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
index 88e1fc8a..3581d31c 100644
--- a/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
+++ b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
@@ -11,7 +11,7 @@ ARG MAVEN_DOWNLOAD_OUTPUT="true"
 ARG MAVEN_OFFLINE_MODE="true"
 
 # Copy from build context to resources directory
-COPY ./ ./resources/
+COPY --chown=1001 . ./resources
 
 # Build app with given resources
 RUN "${KOGITO_HOME}"/launch/build-app.sh './resources'
diff --git a/tests/shell/kogito-swf-builder/resources/greet/Dockerfile 
b/tests/shell/kogito-swf-builder/resources/greet/Dockerfile
index a8e4bdd1..3581d31c 100644
--- a/tests/shell/kogito-swf-builder/resources/greet/Dockerfile
+++ b/tests/shell/kogito-swf-builder/resources/greet/Dockerfile
@@ -11,7 +11,7 @@ ARG MAVEN_DOWNLOAD_OUTPUT="true"
 ARG MAVEN_OFFLINE_MODE="true"
 
 # Copy from build context to resources directory
-COPY * ./resources/
+COPY --chown=1001 . ./resources
 
 # Build app with given resources
 RUN "${KOGITO_HOME}"/launch/build-app.sh './resources'


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to