Dockerizing WSO2 hospital service jar

In this blog post, we are going to build a Docker container to run the hospital service backend jar used in WSO2 Enterprise Integrator samples. Sources for this project are available in this GitHub repo.

Steps to create, run and test the hospital service docker container

  1. Create a new folder and download the Hospital-Service-2.0.0-EI7.jar file and Dockerfile into the folder.

  2. Open a Powershell window and navigate to the folder where files are downloaded to.

  3. Execute “docker build -t hospitalserviceagent:v1 .” to create the Docker image.

  4. Execute “docker run -p 9090:9090 hospitalserviceagent:v1” to run a container based on the created image.

  5. Navigate to http://localhost:9090/healthcare/surgery in a browser window and you should see an output as in step 5 in Sending requests to the ESB.


This Hospital-Service-2.0.0-EI7.jar file in the above repository is downloaded from the WSO2 Docs GitHub repo. Instead of using the jar file link from above step 1, you can use the jar file from the WSO2 Docs repo


Explanation

Now let’s look at the operation of the Docker file. First, it establishes a base image to build our image upon in line 1. In this case, we are using openjdk:8-jre-slim image. Then in line 2, we set a work directory, where we are going to copy the jar file into and execute from. In line 3 we copy the downloaded jar file into our new Docker image’s working directory (in this case to a directory named “app”  in the root directory). Line 4 exposes port number 9090 to the external world from the image, since that is the port where the hospital service is going to listen on when executed. Finally, in line 5 we execute the copied jar file in the container, starting a hospital service instance listening on port 9090 of the container. 


When running the container in above step 4, we have mapped the container’s exposed port 9090, to our localhost port 9090 so that we can access it to verify the service’s operation. Note that we can map the container’s exposed port 9090 onto any available port of the host machine.


Comments

Popular posts from this blog

Running a Docker build agent on Azure Kubernetes Service (AKS)

Azure DevOps Docker DotNet Build Agent

Creating PartsUnlimited Azure DevOps Sample project