-
Notifications
You must be signed in to change notification settings - Fork 178
OpenShift WildFly Quickstarts SNAPSHOT dependencies
The WildFly images uses s2i. They expect to configure a github repository
which will be taken and build in OpenShift environment.
We usually want to build one of the quickstarts folders (that provides a war
file
in the target
directory). For that we will use the -p GIT_CONTEXT_DIR
and then how the build gets the
quickstart-parent
artifact in version -SNAPSHOT
?
Hardly, we need to provide it to the build somehow.
There are more options.
Here we will update the base WildFly s2i image
and inject there the jar
files under the local maven repo - the directory
that’s used with s2i image on build, i.e. -Dmaven.repo.local=/tmp/artifacts/m2
.
-
Install builder image streams
oc create -f https://raw.githubusercontent.com/wildfly/wildfly-s2i/v22.0/imagestreams/wildfly-centos7.json
-
Install runtime image streams
oc create -f https://raw.githubusercontent.com/wildfly/wildfly-s2i/v22.0/templates/wildfly-runtime-imagestream.yml
-
Deploy chain build template
oc create -f https://raw.githubusercontent.com/wildfly/wildfly-s2i/v22.0/templates/wildfly-s2i-chained-build-template.yml
As you can see the yaml
works with WildFly 22.0.0.Final.
Let’s say we have the quickstart in version
23.0.0.Final-SNAPSHOT.
Creating a new helloword application would be like
oc new-app --template=wildfly-s2i-chained-build-template \
-p IMAGE_STREAM_NAMESPACE=$(oc project -q) \
-p APPLICATION_NAME=helloworld -p GIT_REPO=https://github.com/wildfly/quickstart.git \
-p GIT_BRANCH=main -p GIT_CONTEXT_DIR=helloworld
The template wildfly-s2i-chained-build-template
will use the image from the ImageStream wildfly
,
tag latest
. The ImageStream was created above within wildfly-cenots7.json
.
We can check what’s the image from the ImageStream with oc get istag/wildfly:latest
.
The build with -SNAPSHOT
dependencies fail on nexus download error
Could not find artifact org.wildfly.quickstarts:quickstart-parent:pom:23.0.0.Final-SNAPSHOT in central (https://repo1.maven.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 21, column 13
Let’s inject the maven repository to docker/podman image. First we need the maven repository, second updating the base image, third pushing the created image as a new image to wildfly ImageStream.
## Building projects
# expecting the main branch is in version 23.0.0.Final-SNAPSHOT currently
git clone https://github.com/wildfly/wildfly
cd wildfly
mvn clean install -DskipTests
cd -
git clone https://github.com/wildfly/boms
cd boms
mvn clean install
cd -
git clone https://github.com/wildfly/quickstarts
cd quickstarts
mvn clean install -pl .,helloword
cd -
## Creating local repo to be injected
TMP_DIR='/tmp'
mkdir -p "${TMP_DIR}"/artifacts/m2
mkdir -p "${TMP_DIR}"/artifacts/m2/org/wildfly/quickstarts/quickstart-parent/
cp -r ~/.m2/repository/org/wildfly/quickstarts/quickstart-parent/* "${TMP_DIR}"/artifacts/m2/org/wildfly/quickstarts/quickstart-parent/
mkdir -p "${TMP_DIR}"/artifacts/m2/org/wildfly/quickstarts/helloworld
cp -r ~/.m2/repository/org/wildfly/quickstarts/helloworld/* "${TMP_DIR}"/artifacts/m2/org/wildfly/quickstarts/helloworld
mkdir -p "${TMP_DIR}"/artifacts/m2/org/wildfly/bom/
cp -r ~/.m2/repository/org/wildfly/bom/* "${TMP_DIR}"/artifacts/m2/org/wildfly/bom/
# optionally speeding-up the OpenShift build process as we download here
cd quickstarts
mvn clean install -Dmaven.repo.local="${TMP_DIR}"/artifacts/m2 -pl .,helloworld
When repository is filled with the built -SNAPSHOT
artifacts we can push
it to the base image.
# verify the image name with exploring the ImageStream (e.g. oc describe is wildfly | grep 'tagged from')
export THE_IMAGE=quay.io/wildfly/wildfly-centos7:latest
# export THE_IMAGE=registry-proxy.engineering.redhat.com/rh-osbs/jboss-eap-7-tech-preview-eap74-openjdk11-openshift-rhel8:7.4.0.Beta-4
podman pull $THE_IMAGE
# podman rm build_container
podman create --name build_container $THE_IMAGE
cd "${TMP_DIR}" # cd /tmp
# a 'cp' workaround to define owner of the copied files in the container
tar -cf - artifacts --mode u=+rwx,g=+rwx,o=+rwx --owner jboss:185 --group jboss:185 | podman cp --extract - build_container:/tmp/
podman commit build_container default-route-openshift-image-registry.apps-crc.testing/$(oc project -q)/wildfly:latest
# let's push to CRC registry
podman push default-route-openshift-image-registry.apps-crc.testing/$(oc project -q)/wildfly:latest --tls-verify=false
Note
|
|
Note
|
With troubles on pushing to CRC registry try the steps from ../wiki/OpenShift-WildFly-Operator-::-Step-by-Step#configure-crc-registry |
With podman push
the build on OpenShift should be triggered and
the app should be built successfully (oc logs -f helloworld-build-artifacts-2-build
).
Starting application (creating Deployment
)
# for helloworld
oc new-app $(oc project -q)/helloworld
# to delete
oc delete svc,deploy helloworld
# for ejb-txn-remote-call/client
oc new-app $(oc project -q)/client -e JAVA_OPTS_APPEND='-Dwildfly.config.url=$JBOSS_HOME/standalone/configuration/custom-config.xml' \
-e DB_SERVICE_PREFIX_MAPPING='test-postgresql=TEST' -e TEST_USERNAME=test -e TEST_PASSWORD=test -e TEST_DATABASE=test \
-e TEST_DRIVER=postgresql -e TEST_POSTGRESQL_SERVICE_HOST=postgresql -e TEST_POSTGRESQL_SERVICE_PORT=5432 -e TEST_NONXA=false \
-e TEST_JNDI='java:jboss/datasources/ejbJtaDs' -e KUBERNETES_NAMESPACE=$(oc project -q) -e STATEFULSET_HEADLESS_SERVICE_NAME=client