1

There are many companies/people migrating their OpenShift v2 applications to OpenShift Pro due to the imminent sunset of OpenShift 2.

The OpenShift v2 folder .openshift no longer features in OpenShift Pro and RedHat's migration documentation actually states it should be removed.

But what if you have actually used a feature exposed by .openshift such as Tomcat settings? For example tomcat-users.xml or server.xml.

I, myself have used server.xml to specify an addition docBase.

<Context docBase="${OPENSHIFT_DATA_DIR}/documents" path="/documents" />

What am I to do?

How is this achieved in OpenShift Pro?

Is it no longer possible to do?

Is it frowned upon?

Now we are paying customers, perhaps someone at RedHat (or elsewhere) could enlighten us...

Lyndon
  • 573
  • 6
  • 24

1 Answers1

1

The document has the answer (not tried):

  1. All WAR files from the deployments source repository directory are copied to /opt/webserver/webapps.

  2. All files in the configuration source repository directory are copied to /opt/webserver/conf.

If you want to use custom Tomcat configuration files, the file names should be the same as for a normal Tomcat installation. For example, context.xml and server.xml.

Try logging to pod shell via oc rhc <pod_id> and explore /opt/webserver/conf area.

EDIT 1 -

With each deployment, the server is rebuilt and changes to server.xml would be lost. So, all the config files should be part of the repo from which the image is created.

If you are using maven build and would like a cutom deployment of config file like server.xml, check this article

Sample POM given here.

EDIT 2

Another simpler approach suggested by @Lyndon in the comments

All you need to do is create a folder called configuration under the top level git folder. Any file you put in there will get copied to: /opt/webserver/conf. It really is that simple.

Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
  • Thanks gyan but when I added the docBase line to server.xml in the /opt/webserver/conf folder, the file was overwritten and the change lost in the subsequent deployment. I will recheck that that was what happened... – Lyndon Sep 27 '17 at 16:29
  • I believe, you should deploy this via repo/git. I mean checkin your server.xml to repo and let the build process take care of deployment. Because each deployment is similar to rebuilding a fresh server from scratch, any config changes has to come via a repo. – Gyanendra Dwivedi Sep 27 '17 at 16:44
  • That's how it used to work but from the .openshift folder. That;s no longer used. Where exactly would I put my server.xml file now? It exists in tomcat/conf folder not in git. This should be easy (like it used to be)... – Lyndon Sep 27 '17 at 16:55
  • Added more details. You should look here to see how it is done using maven - https://stackoverflow.com/questions/23101945/run-tomcat-and-deploy-project-with-own-server-xml – Gyanendra Dwivedi Sep 27 '17 at 17:08
  • 2
    You got me onto the right path but it is much simpler than was suggested by those articles. All you need to do is create a folder called configuration under the top level git folder. Any file you put in there will get copied to: /opt/webserver/conf. It really is that simple... – Lyndon Sep 27 '17 at 18:06
  • Sadly, although this method does indeed deploy the server.xml, the deployment of the pod fails with this: Caused by: java.lang.IllegalArgumentException: The main resource set specified [/deployments/${OPENSHIFT_DATA_DIR}/documents] is not valid - For some strange reason '/deployments' has been added to the path. This will become a new question tomorrow... – Lyndon Sep 27 '17 at 18:54
  • Try to set environment variable through .s2i/bin/run just before execution. Please check my answer in https://stackoverflow.com/questions/46466516/openshift-migration-env-variables-in-conf-file-not-replaced-as-before – Gyanendra Dwivedi Sep 28 '17 at 16:37