Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some updates proposed to your repository #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM quay.io/centos/centos:stream9

LABEL maintainer="[email protected]"

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"]
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
<Proxy "balancer://mycluster">
BalancerMember "http://localhost:8008/sample"
BalancerMember "http://localhost:8009/sample"
</Proxy>
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/)