Questo contenuto non è disponibile nella lingua selezionata.
Chapter 9. Configuring custom Maven mirrors
OpenShift Serverless Logic uses Maven Central by default to resolve Maven artifacts during workflow builds. The provided builder and development images include all required Java libraries to run workflows, but in certain scenarios, such as when you add a custom Quarkus extension, you must download the additional dependencies from Maven Central.
In environments with restricted or firewalled network access, direct access to Maven Central might not be available. In such cases, you can configure the workflow containers to use a custom Maven mirror, such as an internal company registry or repository manager.
You can configure a custom Maven mirror at different levels as follows:
-
Per workflow build by updating the
SonataFlowBuildcustom resource. -
At the platform level by updating the
SonataFlowPlatformcustom resource. -
For development mode deployments by editing the
SonataFlowcustom resource. - When building custom images externally with the builder image
9.1. Adding a Maven mirror when building workflows Copia collegamentoCollegamento copiato negli appunti!
You can configure a Maven mirror by setting the MAVEN_MIRROR_URL environment variable in the SonataFlowBuild or SonataFlowPlatform custom resources (CR).
The recommended approach is to update the SonataFlowPlatform CR. This ensures the mirror configuration is propagated automatically to all workflow builds within the platform scope.
Prerequisites
- You have OpenShift Serverless Logic Operator installed on your cluster.
- You have created your OpenShift Serverless Logic project.
- You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
- You have access to a custom Maven mirror or internal repository.
Procedure
Edit the
SonataFlowPlatformCR to configure a Maven mirror for all workflow builds in a namespace, as shown in the following example:Example of Maven mirror configuration in a
SonataFlowPlatformCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow This configuration applies to all workflow builds in the same namespace that use the
previewprofile. When a workflow builder instance runs, it updates the internal Maven settings file to use the specified mirror as the default for external locations such as Maven Central.Optional: If you need a specific configuration for a single workflow build, create the
SonataFlowBuildCR before creating the correspondingSonataFlowCR. TheSonataFlowBuildandSonataFlowCRs must have the same name.Example of Maven mirror configuration in a
SonataFlowBuildCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can use the
SonataFlowBuildCR configuration only when you require workflow-specific behavior, for example, debugging. For general use, configure theSonataFlowPlatformCR instead.
9.2. Adding a Maven mirror when deploying in development mode Copia collegamentoCollegamento copiato negli appunti!
You can configure a Maven mirror for workflows that run in dev mode by adding the MAVEN_MIRROR_URL environment variable to the SonataFlow custom resource (CR).
Prerequisites
- You have created your OpenShift Serverless Logic project.
- You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
-
You have a workflow deployed in
devprofile. - You have access to a custom Maven mirror or internal repository.
Procedure
Edit the
SonataFlowCR to include the Maven mirror configuration as shown in the following example:Example of Maven mirror configuration on SonataFlow CR
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
MAVEN_MIRROR_URLvariable specifies the custom Maven mirror.
Only workflows deployed with the dev profile can use Maven mirrors. Other deployment models run compiled code only, so they do not need to connect to a Maven registry.
9.3. Configuring a Maven mirror on a custom image Copia collegamentoCollegamento copiato negli appunti!
You can configure a Maven mirror for workflows that run in dev mode by adding the MAVEN_MIRROR_URL environment variable to the SonataFlow custom resource (CR).
Prerequisites
- You have created your OpenShift Serverless Logic project.
- You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
- You have access to a dockerfile or container build context that uses the SonataFlow Builder image.
- You have access to a custom Maven mirror or internal repository.
Procedure
Set the Maven mirror as an environment variable in the Dockerfile as shown in the following example:
Example of custom container file with Maven mirror set as an environment variable
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
ENVdirective ensures that all builds with this Dockerfile automatically use the specified Maven mirror.Set the Maven mirror as a build-time argument in the Dockerfile as shown in the following example:
Example of custom container file with Maven mirror set as an argument
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
ARGdirective allows you to pass the Maven mirror value dynamically at build time.