Containerized a basic "Hello World" Vertx project with a unit test (https://github.com/bassdude5/Vertx_HelloWorld)
- Login to OpenShift:
oc login
- Login to Docker:
docker login -u username -p $(oc whoami -t) docker.registry.url
- Create a new OpenShift project:
oc new-project vertx
- Build the app to get the jar (note the jar name needs to be the same as the jar name specified in the Dockerfile):
mvn clean install
- Build the image (here we are specifying the openshift namespace so the image can be accessed across all namespaces):
docker build -t openshift/java-fat-jar-example:latest .
- View the image:
docker images
- Tag the image with docker.registry/image-name:version
docker tag openshift/java-fat-jar-example docker.registry.url/openshift/java-fat-jar-example:latest
- Push the image to the internal registry:
docker push docker.registry.url/openshift/java-fat-jar-example:latest
- Create the application (make sure you're in the correct namespace):
oc new-app --docker-image=docker.registry.url/openshift/java-fat-jar-example:latest
- Verify that your pods are up:
oc get pods
- Edit the service to route through port 8081 (as this app requires). Change the port, target port and the port name:
oc edit svc servicename
- Confirm that the service is correct:
oc describe svc servicename
- Expose the service:
oc expose svc servicename
- get the route:
oc get route
- Access the route via comand line or open in your browser:
curl route