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-docs.git


The following commit(s) were added to refs/heads/main by this push:
     new 2b25293ff [KOGITO-9839] - Add how to build a custom devmode image 
(#508)
2b25293ff is described below

commit 2b25293ffaae14318e112a878b2285de14f62d38
Author: Ricardo Zanini <[email protected]>
AuthorDate: Fri Sep 29 10:00:34 2023 -0300

    [KOGITO-9839] - Add how to build a custom devmode image (#508)
    
    * [KOGITO-9839] - Add how to build a custom devmode image
    
    Signed-off-by: Ricardo Zanini <[email protected]>
    
    * Apply suggestions from code review
    
    Co-authored-by: Filippe Spolti <[email protected]>
    Co-authored-by: Kalyani Desai <[email protected]>
    Co-authored-by: Walter Medvedeo <[email protected]>
    
    ---------
    
    Signed-off-by: Ricardo Zanini <[email protected]>
    Co-authored-by: Filippe Spolti <[email protected]>
    Co-authored-by: Kalyani Desai <[email protected]>
    Co-authored-by: Walter Medvedeo <[email protected]>
---
 serverlessworkflow/antora.yml                      |   1 +
 serverlessworkflow/modules/ROOT/nav.adoc           |   1 +
 .../modules/ROOT/pages/cloud/index.adoc            |   8 ++
 .../cloud/operator/building-custom-images.adoc     | 138 +++++++++++++++++++++
 .../pages/cloud/operator/developing-workflows.adoc |   5 +-
 5 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/serverlessworkflow/antora.yml b/serverlessworkflow/antora.yml
index 44fbdaabb..00580446e 100644
--- a/serverlessworkflow/antora.yml
+++ b/serverlessworkflow/antora.yml
@@ -43,6 +43,7 @@ asciidoc:
     operator_k8s_keyword: sonataflow
     operator_k8s_subscription: my-sonataflow-operator
     kogito_devservices_imagename: 
registry.redhat.io/openshift-serverless-1-tech-preview/logic-data-index-ephemeral-rhel8
+    sonataflow_devmode_imagename: quay.io/kiegroup/kogito-swf-devmode
     kogito_examples_repository_url: https://github.com/kiegroup/kogito-examples
     kogito_sw_examples_url: 
https://github.com/kiegroup/kogito-examples/tree/main/serverless-workflow-examples
     kogito_examples_url: https://github.com/kiegroup/kogito-examples.git
diff --git a/serverlessworkflow/modules/ROOT/nav.adoc 
b/serverlessworkflow/modules/ROOT/nav.adoc
index 8eeca65eb..9a90f16ad 100644
--- a/serverlessworkflow/modules/ROOT/nav.adoc
+++ b/serverlessworkflow/modules/ROOT/nav.adoc
@@ -72,6 +72,7 @@
 *** xref:cloud/operator/configuring-workflows.adoc[Configuration]
 *** xref:cloud/operator/build-and-deploy-workflows.adoc[Building and Deploying 
Workflow Images]
 *** xref:cloud/operator/workflow-status-conditions.adoc[Custom Resource Status]
+*** xref:cloud/operator/building-custom-images.adoc[Building Custom Images]
 *** xref:cloud/operator/known-issues.adoc[Roadmap and Known Issues]
 *** xref:cloud/operator/migration-guide.adoc[]
 ** Quarkus
diff --git a/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc 
b/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc
index 9eec23bc7..8e88b7809 100644
--- a/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc
+++ b/serverlessworkflow/modules/ROOT/pages/cloud/index.adoc
@@ -69,6 +69,14 @@ xref:cloud/operator/build-and-deploy-workflows.adoc[]
 Learn how to build and deploy workflow services with {operator_name}
 --
 
+[.card]
+--
+[.card-title]
+xref:cloud/operator/building-custom-images.adoc[]
+[.card-description]
+Learn how to build a custom development image to use with SonataFlow in devmode
+--
+
 [.card]
 --
 [.card-title]
diff --git 
a/serverlessworkflow/modules/ROOT/pages/cloud/operator/building-custom-images.adoc
 
b/serverlessworkflow/modules/ROOT/pages/cloud/operator/building-custom-images.adoc
new file mode 100644
index 000000000..b03124069
--- /dev/null
+++ 
b/serverlessworkflow/modules/ROOT/pages/cloud/operator/building-custom-images.adoc
@@ -0,0 +1,138 @@
+= Building a Custom Development Image
+:compat-mode!:
+// Metadata:
+:description: Building custom development images for SonataFlow
+:keywords: sonataflow, workflow, serverless, operator, kubernetes, minikube, 
devmode
+// Links:
+:rh_ubi8_url: 
https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8
+
+// NOTE: this guide can be expanded in the future to include prod images, 
hence the file name
+//       please change the title section and rearrange the others once it's 
done
+
+This document describes how to build a custom development image to use in 
SonataFlow.
+
+== The development mode image structure
+
+The development image is based on the link:{rh_ubi8_url}[Red Hat UBI 8 
minimal] container image. You can read its documentation for more detailed 
information about that image's architecture.
+
+The table below lists the additional packages installed in the development 
mode container image.
+
+.List of packages
+[cols="1,2"]
+|===
+|Package | Description
+
+|shadow-utils
+|The shadow-utils package includes the necessary programs for converting UNIX 
password files to the shadow password format.
+
+|tar
+|
+
+|gzip
+|
+
+|unzip
+|
+
+|zip
+|
+
+|tzdata-java
+|
+
+|java-11-openjdk-devel
+|OpenJDK 11
+
+|apache-maven-3.8.6-bin.tar.gz
+|Apache Maven
+
+|===
+
+The next table lists the important paths in the container image's file system.
+
+.Important file system paths
+[cols="1,1"]
+|===
+|Path | Description
+
+|`/home/kogito`
+|Default user home directory
+
+|`/home/kogito/launch`
+|Useful scripts to run the application
+
+|`/home/kogito/serverless-workflow-project`
+|Workflow application directory in Maven format
+
+|`/home/kogito/.m2/repository`
+|Default Maven cache repository
+
+|===
+
+== Using the development mode as base image
+
+Below you can find an example of a Dockerfile using the dev mode image as a 
base image to run a workflow capable of executing Python scripts.
+
+.Example of a dev mode Dockerfile
+[source,dockerfile,subs="attributes+"]
+----
+FROM {sonataflow_devmode_imagename}:{operator_version} <1>
+
+USER root <2>
+
+RUN microdnf install -y --nodocs python311 gcc python3.11-devel mesa-libGLU && 
\ <3>
+    microdnf clean all && \
+    ln -s /usr/bin/python3 /usr/bin/python && \
+    curl -sSL https://bootstrap.pypa.io/get-pip.py | python
+
+USER 1001 <4>
+
+ENV PATH="$\{PATH\}:/home/kogito/.local/bin" <5>
+
+COPY requirements.txt /home/kogito/serverless-workflow-project/ <6>
+
+RUN pip install numpy
+RUN pip install -r requirements.txt
+
+ENV 
QUARKUS_EXTENSIONS="org.kie.kogito:kogito-addons-quarkus-serverless-workflow-python:{page-component-display-version}"
 <7>
+
+CMD ["/home/kogito/launch/run-app-devmode.sh"] <8>
+----
+
+<1> The dev mode image as the base image
+<2> Change to super user to run privileged actions
+<3> Install additional packages
+<4> Change back to the default user without admin privileges
+<5> Add a new binary path to the `PATH`
+<6> Copying a file to the project's root path
+<7> Optionally adding a new Quarkus addon to the project
+<8> Defining the default entrypoint for the image
+
+You can then build this image using the following command:
+
+.Example of building a custom dev mode image
+[source,shell,subs="attributes+"]
+----
+docker build -t quay.io/acme/sonataflow-python-devmode:latest .
+----
+
+You can experiment with your new image running the container locally, for 
example:
+
+.Running the custom dev mode image locally
+[source,shell,subs="attributes+"]
+----
+ docker run -it --rm -p 8080:8080 -v 
/path/to/my/local/project/resources:/home/kogito/serverless-workflow-project/src/main/resources
 quay.io/acme/sonataflow-python-devmode:latest
+----
+
+The container exposes port 8080 by default. When running the container 
locally, you must forward any free local port to 8080. In this example, we use 
the same 8080 port.
+
+Next, we mount a local volume to the container's application path. Any local 
workflow definitions, specification files, or properties should be mounted to 
`src/main/resources`. Alternatively, you can also mount custom Java files to 
`src/main/java`.
+
+Finally, to use the new generated image with the dev profile you can see: 
xref:cloud/operator/developing-workflows.adoc#_using_another_workflow_base_image[Using
 another Workflow base image].
+
+== Additional resources
+
+* xref:cloud/operator/referencing-resource-files.adoc[]
+* xref:cloud/operator/developing-workflows.adoc[]
+
+include::../../../pages/_common-content/report-issue.adoc[]
\ No newline at end of file
diff --git 
a/serverlessworkflow/modules/ROOT/pages/cloud/operator/developing-workflows.adoc
 
b/serverlessworkflow/modules/ROOT/pages/cloud/operator/developing-workflows.adoc
index 1cd0530b9..9a9da4478 100644
--- 
a/serverlessworkflow/modules/ROOT/pages/cloud/operator/developing-workflows.adoc
+++ 
b/serverlessworkflow/modules/ROOT/pages/cloud/operator/developing-workflows.adoc
@@ -1,4 +1,4 @@
-= Developing Workflow with the Operator
+= Developing Workflows with the Operator
 :compat-mode!:
 // Metadata:
 :description: Developing workflows with the operator on Kubernetes
@@ -228,7 +228,7 @@ From now on, every deployment in the development profile 
will use this image to
 
 [IMPORTANT]
 ====
-The default image was created to run a Quarkus Java application in dev mode. 
You can replace this image with another one as long as it has the same concept. 
One way of doing this is using the default as the base image.
+The default image was created to run a Quarkus Java application in dev mode. 
You can replace this image with another one as long as it has the same concept. 
One way of doing this is using the default as the base image. See 
xref:cloud/operator/building-custom-images.adoc[].
 ====
 
 [[troubleshooting]]
@@ -304,5 +304,6 @@ If you find an issue with a cause is not listed in this 
section, please link:{do
 
 * xref:cloud/operator/referencing-resource-files.adoc[]
 * xref:cloud/operator/build-and-deploy-workflows.adoc[]
+* xref:cloud/operator/building-custom-images.adoc[]
 
 include::../../../pages/_common-content/report-issue.adoc[]


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

Reply via email to