diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..9a51ba2 --- /dev/null +++ b/Containerfile @@ -0,0 +1,14 @@ +FROM quay.io/centos/centos:stream9 + +LABEL maintainer="emverdes@gmail.com" + +RUN dnf install -y java-11-openjdk && dnf clean all + +RUN mkdir /opt/tomcat + +RUN curl -O https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.tar.gz && tar xvfz apache*.tar.gz && mv apache-tomcat-8.5.100/* /opt/tomcat/. + +ADD sample.war /opt/tomcat/webapps/ + +EXPOSE 8080 +CMD ["/opt/tomcat/bin/catalina.sh", "run"] diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a259ddc..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM tomcat:8.0-alpine -LABEL maintainer="deepak@softwareyoga.com" - -ADD sample.war /usr/local/tomcat/webapps/ - -EXPOSE 8080 -CMD ["catalina.sh", "run"] \ No newline at end of file diff --git a/README.md b/README.md index 53170c6..179b863 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,49 @@ # docker-tomcat-tutorial -A basic tutorial on running a web app on Tomcat using Docker +A basic tutorial on running a web app on Tomcat using Podman (based on a docker tutorial) # Steps -* Install [Docker](https://docs.docker.com/install/). -* Clone this repository - $git clone https://github.com/softwareyoga/docker-tomcat-tutorial.git -* cd 'docker-tomcat-tutorial' -* $docker build -t mywebapp . -* $docker run -p 80:8080 mywebapp -* http://localhost:80 +* Install [podman](https://podman.io/getting-started/installation). +* Clone this repository +``` +$ git clone https://github.com/emverdes/docker-tomcat-tutorial.git + +$ cd docker-tomcat-tutorial +``` +* Verify Tomcat download URL from https://dlcdn.apache.org/tomcat/ to update the Containerfile +``` +$ podman build -t tomcat-demo:1 . + +$ podman run -p 8008:8080 --name demo1 tomcat-demo:1 +``` +* In your browser go to http://localhost:8008 +* Run another instance for load balancing +``` +$ podman run -p 8009:8080 --name demo1 tomcat-demo:1 +``` +# Simple apache reverse proxy +Add to a VirtualHost in your apache web server configuration. +Replace localhost with the hostname of the host running your containers. +Remember to open up the ports in your firewall if needed. + +``` +ProxyPass "/sample" "http://localhost:8008/sample" +ProxyPassReverse "/sample" "http://localhost:8008/sample" +``` + +# Apache proxy loadbalancer for 2 containers +``` + + BalancerMember "http://localhost:8008/sample" + BalancerMember "http://localhost:8009/sample" + +ProxyPass "/" "balancer://mycluster/" +ProxyPassReverse "/" "balancer://mycluster/" +``` + +# For reverse proxy +* #setsebool -P httpd_can_network_connect on +* #setsebool -P httpd_can_network_relay on + # Links [Sample Tomcat web app](https://tomcat.apache.org/tomcat-8.0-doc/appdev/sample/)