Skip to content

Build with unreleased EAP Maven Repository

Jeff Mesnil edited this page Jun 29, 2022 · 2 revisions

With EAP 8.0, the provisioning of the server use Maven to pull the EAP artifacts from JBoss Enterprise Maven Repository.

During the development of EAP release, it is possible to build and deploy EAP 8 application using unreleased EAP artifacts. We rely on the availability of a zip archive of EAP Maven repository to fetch the EAP artifacts during the S2I build.

In order to perform a S2I build with these unreleased artifacts, we need to:

  • download the zip archive of this EAP Maven repository

  • build a docker image that contains the content of the zip archive

  • build this docker image to OpenShift image registry

Once this image is available, we can configure the Helm Charts to inject its content during the S2I build step.

Create a Docker image from a EAP Maven repository.

In order to create a Docker image, we need to download the zip archive, extract its content and put it in scratch Docker image (that contains nothing else)

cd ~/tmp
wget -c <url to jboss-eap-8.0.0 maven-repository.zip> --no-check-certificate
unzip jboss-eap-8.0.0.Beta-redhat-xxxxxxxx-maven-repository.zip

To create the Docker image, we can use a simple Dockerfile:

cd ~/tmp

cat << EOF > Dockerfile
FROM scratch
COPY jboss-eap-8.0.0.Beta-maven-repository/maven-repository /maven-repository
EOF

docker build -t eap-maven-repo .

Push the Docker image of the EAP Maven repository to OpenShift

Once this eap-maven-repo is created, we can push it to the OpenShift image registry to use it as an imagestream:

# change the value to your OpenShift Image Registry Public URL
OC_IMAGE_REGISTRY=default-route-openshift-image-registry.apps....

EAP_MAVEN_REPO_IMAGESTREAM=$OC_IMAGE_REGISTRY/$(oc project -q)/eap-maven-repo
oc registry login
docker login -u openshift -p $(oc whoami -t) $OC_IMAGE_REGISTRY
docker tag eap-maven-repo $EAP_MAVEN_REPO_IMAGESTREAM
docker push $EAP_MAVEN_REPO_IMAGESTREAM
oc get imagestream/eap-maven-repo

Inject the Docker image of the EAP Maven repository during the S2I build

We can access the artifacts from this containerized Maven repository by injecting this image during the S2I build

build:
  images:
    - from:
        kind: ImageStreamTag
        name: 'eap-maven-repo:latest'
      paths:
        - sourcePath: /maven-repository
          destinationDir: ./eap-maven-repo
  env:
    - name: MAVEN_SETTINGS_XML
      value: /tmp/src/ocp-settings.xml

The EAP Maven repository will be present on the file system under the application source code in the directory eap-maven-repo/maven-repository. To be able to use it, we need to use a Maven ocp-settings.xml file that references it:

ocp-settings.xml
<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <profiles>
        <!-- Configure the JBoss EAP Maven repository -->
        <profile>
            <id>jboss-eap-repository</id>
            <repositories>
                <repository>
                    <id>jboss-eap-repository</id>
                    <url>file:///tmp/src/eap-maven-repo/maven-repository</url>
                </repository>
                <repository>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2/</url>
                </repository>
                <repository>
                    <id>redhat-ga-repository</id>
                    <url>https://maven.repository.redhat.com/ga/</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>jboss-eap-plugin-repository</id>
                    <url>file:///tmp/src/eap-maven-repo/maven-repository</url>
                </pluginRepository>
                <pluginRepository>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2/</url>
                </pluginRepository>
                <pluginRepository>
                    <id>redhat-ga-repository</id>
                    <url>https://maven.repository.redhat.com/ga/</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>jboss-eap-repository</activeProfile>
    </activeProfiles>
</settings>

The simplest way to use this ocp-settings.xml is to store it in the application code and specifies to use it during build with the environment variable MAVEN_SETTINGS_XML:

build:
  env:
    - name: MAVEN_SETTINGS_XML
      value: /tmp/src/ocp-settings.xml

Once the Helm Release is created, S2I will inject the Docker image of the EAP Maven repository and the application will use its tcp-settings.xml to be able to fetch any EAP artifacts from it.