This project demonstrate the steps to dockerize a helloworld application from the wildfly quickstart projects.
I would recommend looking at Microservice Builder and also the next generation application development [microclimate](https://microclimate-dev2ops.github.io/.
Microservice Builder is about focus on app development and not the framework where you can used to develop Java EE and MicroProfile.io based programming model.
I have also created another project that's show how you would create the Dockerfile where the same web application can be deployed on WebSphere Liberty.
Course : Migrate traditional WebSphere apps to WebSphere Liberty on IBM Cloud Private by using Kubernetes
- Modernize an application to run on WebSphere Liberty
- Locally build and run the WebSphere Liberty application
- Containerize the WebSphere Liberty application
- Configure Kubernetes for WebSphere Liberty
- Deploy the WebSphere Liberty application from the Kubernetes command line
- Running Liberty applications in IBM Cloud Private
- Migrating WebSphere apps to IBM Cloud Private
- Microservices for fast time to market and improved app quality
- Private cloud for maximum control with the benefits of cloud
To dockerize your web application create a Dockerfile with the following content.
Ensure your web applicatin .war is located in the same folder as the Dockerfile.
FROM jboss/wildfly
ADD helloworld.war /opt/jboss/wildfly/standalone/deployments/
Run the following command to create docker image locally on your machine.
docker build . -t mtl-helloworld
To list the docker images on your machine, execute the following command.
docker images
clean up the images locally
docker rm `docker ps --no-trunc -a -q`
docker images | grep '' | awk '{print $3}' | xargs docker rmi
To test the application dockerize above, you can run your application with the following command.
The command execute the container at port 5000 and you can access your application at http://localhost:5000
docker run -p 5000:8080 mtl-helloworld
alternatively you can test with curl.
$ curl -I http://localhost:5000
HTTP/1.1 200 OK
Connection: keep-alive
Last-Modified: Thu, 01 Mar 2018 06:29:00 GMT
X-Powered-By: Undertow/1
Server: WildFly/11
Content-Length: 2438
Content-Type: text/html
Accept-Ranges: bytes
Date: Wed, 11 Apr 2018 10:47:11 GMT
You can also view the helloworld application with url the below.
http://localhost:5000/helloworld/HelloWorld
To see the running containers, you can use the following command
docker ps
or
docker ps -l
In order for you to push your local image to ICP, you need to add a IP entry in your host file /etc/hosts
assuming your ICP instance has IP : 192.168.64.148 cluster : mycluster.icp
Please create the following line in your /etc/hosts
192.168.64.148 mycluster.icp
You can push images to a specific namespae in ICP.
For example, if you want to push your image to a namespace create a namespace of your choice in ICP using UI or kubectl
e.g. using kubectl, to use kubectl you will need to configure your client to connect to ICP.
kubectl create namespace dev
With the following command you have
- namespace : dev
- tag: 1.0
- image: mtl-helloworld
- ICP cluster repo : mycluster.icp:8500
docker tag mtl-helloworld mycluster.icp:8500/dev/mtl-helloworld:1.0
Before you can push the image to ICP private docker image repo, you need to perform docker login.
on my Mac machine, I login with secured login disable, where I can specify the location of in Daemon in docker engine for insecure registries.
For setup on Linux, please refer to pushing and pulling image in ICP.
docker login mycluster.icp:8500
docker push mycluster.icp:8500/dev/mtl-helloworld:1.0
You can create helm chart for your application where your users can deploy your application through the self service catalog provided by IBM Cloud Private.
To create a helm chart you can run the following command, I have updated the generated templates for containerPort: 8080 in deployment.yaml
. In values.yaml
I have updated the following.
repository: mycluster.icp:8500/dev/mtl-helloworld
tag: "1.0"
Create the helm chart template with the following command
helm create myapp
package your helm chart as a .tgz file.
helm package ./myapp
You can then place your tgz files on a web server with listing of all helm chart files.
For example, if you have a web server https://url/mycharts and your helm chart files are located at local folder charts. You create a index of your helm charts with the following command.
helm repo index charts --url https://url/mycharts
for reference to more helm commands.
You can add your charts to ICP catalog using UI or helm command.
To learn more on using helm with ICP, check out setting up Helm CLI.
Once your chart repo is configured in ICP, your users will be able to deploy your application from ICP catalog.
helm add https://ibmcloudprivate2.github.io/mycharts
You can start test drive ICP using Terraform.
Once you have your ICP, you can test drive CI/CD using GitLab and Jenkins.
you can test drive some application by adding the the repo below to ICP catalog.
https://ibmcloudprivate2.github.io/mycharts/
With the above charts you can test drive deployment of sample application
-
short video of ICP feature usage
- Getting started with reference architectures
- Deploy a Spring Cloud application on IBM Cloud Private
- Microservices for fast time to market and improved app quality
- Building Stock Trader in IBM Cloud Private 2.1 using Production Services
- twelve-factor app
- Best practice for Dokcerfile
- Best practice for docker development
- refer to dotnet app sample for more docker command