How to do it...

  1. After logging in to the platform, you will see this main page:
Openshift main page
  1. Click on the Create Project button and fill in the blanks. Click on Create:
Filling fields for a new project
  1. Once your project is created, click on it:
Access for the new project
  1. On the opened page, click on Add to Project (top right) and then Deploy Image:
Project main page
  1. In the popup select Image Name, fill in the form with our pre-built image (eldermoraes/gf-javaee-cookbook) and click on the Search icon.

You will see a warning like this:

Image deployment popup

Let me save you time: don't deploy it, because it will not work. The OpenShift platform demands that your container should run with a user other than root. So we need to build another image for it.

Fortunately, it's quite simple. The new Dockerfile is like this:

FROM eldermoraes/gf-javaee-jdk8

ENV DEPLOYMENT_DIR ${GLASSFISH_HOME}/glassfish/domains/domain1/autodeploy/

COPY app.war ${DEPLOYMENT_DIR}

USER root

RUN chown -R glassfish:glassfish_grp ${DEPLOYMENT_DIR}/app.war
&& chmod -R 777 ${DEPLOYMENT_DIR}/app.war

USER glassfish
  1. Then you build a new image based on this Dockerfile:
docker build -t eldermoraes/gf-javaee-cookbook-os .
  1. Then push this new image to the Docker Hub:
docker push eldermoraes/gf-javaee-cookbook-os

Now you are good to go:

Image deployment popup
  1. There are no warnings, so go ahead and click on Deploy. In the page that opens, click on the Continue to the project overview label:
Image deployment confirmation
  1. Watch the following page until the pod icon is blue. When it's ready, click on the Create Route link:
Monitoring the pod creation
  1. In the popup, fill in the Path field with /app and in Target Port choose 8080 -> 8080 (TCP):
Route creation
  1. Click on Create and wait:
Route confirmation
  1. Once it's done, click on the Overview menu (top left). In the same row as the application name, there's a URL pointing to your container:
Test page for our application

If you can see the page, congratulations! Your application is now orchestrated at OpenShift.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.218.226