Chapter 7. 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
SonataFlowBuild
custom resource. -
At the platform level by updating the
SonataFlowPlatform
custom resource. -
For development mode deployments by editing the
SonataFlow
custom resource. - When building custom images externally with the builder image
7.1. Adding a Maven mirror when building workflows Copy linkLink copied to clipboard!
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
SonataFlowPlatform
CR 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
SonataFlowPlatform
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow This configuration applies to all workflow builds in the same namespace that use the
preview
profile. 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
SonataFlowBuild
CR before creating the correspondingSonataFlow
CR. TheSonataFlowBuild
andSonataFlow
CRs must have the same name.Example of Maven mirror configuration in a
SonataFlowBuild
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can use the
SonataFlowBuild
CR configuration only when you require workflow-specific behavior, for example, debugging. For general use, configure theSonataFlowPlatform
CR instead.
7.2. Adding a Maven mirror when deploying in development mode Copy linkLink copied to clipboard!
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
dev
profile. - You have access to a custom Maven mirror or internal repository.
Procedure
Edit the
SonataFlow
CR 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_URL
variable 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.
7.3. Configuring a Maven mirror on a custom image Copy linkLink copied to clipboard!
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
ENV
directive 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
ARG
directive allows you to pass the Maven mirror value dynamically at build time.