Java + Tomcat + PostgreSQL
Apache Tomcat as a servlet container and PostgreSQL as the database.
The Tomcat Stack variant for projects that already work with PostgreSQL or that need its advanced data types, such as native JSON or full-text search.
Included services
In addition to your application, the Stack brings up PostgreSQL, an nginx that receives traffic on port 80, an automatic backups service and the web file manager.
Project structure
.
βββ app
β βββ META-INF
β β βββ MANIFEST.MF
β βββ WEB-INF
β β βββ ...
β β βββ web.xml
β βββ images
β β βββ tomcat.gif
β βββ MANIFEST.MF
β βββ hello.jsp
β βββ index.html
β βββ status.json
βββ backup
β βββ backup-runner.sh
βββ nginx
β βββ default.conf
βββ .env.example
βββ app.Dockerfile
βββ compose.yaml
Getting started
Install the Stack and bring it up:
docker-deploy-stack --stack java/tomcat-postgres
cd /root/stack/java/tomcat-postgres
docker compose up -d
Then replace the example application with yours, via Git, by SFTP or from the web file manager, following como-despliego-una-aplicacion-en-un-stack.md. Your code goes in the app/ folder.
Each time you update the code, apply the changes:
docker compose up -d --build
Configuration
Editable values are in the Stackβs .env file:
| Variable | Default | Purpose |
|---|---|---|
APP_PORT |
80 |
Public port of the Stack. |
APP_ENV |
development |
Application environment. |
DB_NAME |
example |
Database name. |
BACKUP_ENABLED |
1 |
Automatic backups: 1 enabled, 0 disabled. |
BACKUP_INTERVAL_SECONDS |
86400 |
How many seconds between backups. |
BACKUP_RETENTION_DAYS |
7 |
How many days backups are kept. |
POSTGRES_VERSION |
16-alpine |
Version of the corresponding image. |
After changing it, apply the changes with docker compose up -d.
Useful commands
docker compose ps # see the containers that are running
docker compose logs -f # view live logs
docker compose restart # restart the services
docker compose down # stop and remove the containers