Setup JSP Tomcat Docker from GitHub Gist

[1] Start Your Docker Playground
Create a new instance.
[2] Prepare the Setup Script
In the terminal window, type:
touch get-setup-script.sh
Click the Editor button at the top of the terminal window.
In the editor, open the file get-setup-script.sh.
Paste the following code into the file:
curl -fsSL https://gist.githubusercontent.com/mohamadrazzimy/da1c5df7e8160ae03bbde499f4b1b516/raw/6932c9cd6d70bc40d9e84c830bc8df94367e2218/setup-jsp-tomcat-docker.sh -o setup-jsp-tomcat-docker.sh
Example:

To execute the script, run the following command:
bash get-setup-script.sh
This will download the setup-jsp-tomcat-docker.sh file to the root directory. You can verify this by using the ls command.
Example:

[3] Run the Setup Script
Execute the setup script by running:
bash setup-jsp-tomcat-docker.sh
This script will download a zipped project from GitHub and unzip it.
Example:

Notice the folder jsp-tomcat-docker-main.
[4] Run the Docker Compose Script
Navigate to the project folder using the cd command.
Check the contents of the folder with the ls command.
Example:

You should notice a file named docker-compose.yml.
To launch the Docker containers, run:
docker-compose up -d
Example:

You can verify using the following command:
docker ps
Example:

You should see a clickable button for port 8080 at the top of the page.
If it doesn’t appear, click the OPEN PORT button, enter 8080, and you should be able to access the port via your web browser.
Example:

You should see the following page:

APPENDIX
[1] docker-compose.yml
version: '3.8'
services:
tomcat:
image: tomcat:9-jdk17
ports:
- "8080:8080"
volumes:
- ./webapp:/usr/local/tomcat/webapps/ROOT
# Optional: Wait for startup to complete before marking as "healthy"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
interval: 10s
timeout: 5s
retries: 5
[2] webapp/index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head><title>Hello JSP</title></head>
<body>
<h1>Hello from Docker Compose!</h1>
<p>Server time: <%= new java.util.Date() %></p>
</body>
</html>



