- After logging in to the platform, you will see this main page:
Openshift main page
- Click on the Create Project button and fill in the blanks. Click on Create:
Filling fields for a new project
- Once your project is created, click on it:
Access for the new project
- On the opened page, click on Add to Project (top right) and then Deploy Image:
Project main page
- 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
- Then you build a new image based on this Dockerfile:
docker build -t eldermoraes/gf-javaee-cookbook-os .
- 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
- 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
- Watch the following page until the pod icon is blue. When it's ready, click on the Create Route link:
Monitoring the pod creation
- In the popup, fill in the Path field with /app and in Target Port choose 8080 -> 8080 (TCP):
Route creation
- Click on Create and wait:
Route confirmation
- 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.