This repository demonstrates how to package a Java web application (WAR) and run it locally inside a Tomcat container using either Podman or Docker.
- Container Runtime: Either
podman(recommended) ordocker. - Environment Setup Tools:
vaultandjqare required for retrieving credentials during the build process. - Tomcat Runtime: Provided via a container image; no local Tomcat installation is needed.
- The included
Dockerfilesupports rootless runtime by passingUSER_IDandGROUP_IDas build arguments. Defaults are1000. - The build script (
build.sh) attempts to authenticate with Vault to retrieve Artifactory credentials. This is required for applications with custom dependencies hosted in Artifactory.
Run:
./build.sh --engine podmanor
./build.sh --engine=podmanRun:
./build.sh --engine dockeror
./build.sh --engine=dockerThis performs the same build process using Docker.
Run:
./run.sh podmanThis launches the application inside a Tomcat container.
podman logs --tail 200 myapp
curl -sS -D - http://localhost:8080/ -o /dev/nullExpected output: HTTP/1.1 200
podman exec myapp id -u
podman exec myapp id -gIf you want to change the default Tomcat port, JVM options or runtime user, then update .docker/runtime/Dockerfile and run.sh accordingly.
This repository uses the Polaris Pipeline to build and deploy.
Refer to nr-polaris-docs for more information about how to use the Polaris Pipeline.
NRM Architecture Confluence: GitHub Repository Best Practices
Use the env.sh script to initialize your build or development runtime environment.
Refer to nr-polaris-docs for more information on how env.sh sets up the build environment.
source env.sh [mode] [path] [--skip-vault]Parameters:
mode:build(default) orlocalbuildmode: Setup for buildslocalmode: Setup for local development runtime
path: Directory containing catalog-info.yaml (default: current directory)--skip-vault: Skip Vault authentication (for offline/CI scenarios)
# Load build environment
source env.sh
# Load local development runtime environment
source env.sh local
# Skip Vault authentication
source env.sh build --skip-vaultThe pom.xml uses a VERSION environment variable and the ${revision} property for the project version (see https://maven.apache.org/guides/mini/guide-maven-ci-friendly.html).
A profile named version-from-env activates automatically when the VERSION environment variable is present and sets ${revision} to its value.
When the environment variable is absent, the POM uses the hardcoded value in the properties section.
The Flatten Maven Plugin is used for install / deploy as described in the official Maven CI Friendly guide.
| Context | Version resolved |
|---|---|
| Local build — no env var, no env.sh | Maven builds with version UNSET (clearly invalid, won't be mistaken for a real release) |
Local build — after source env.sh |
.env-build.sh reads the base version from VERSION file (unless VERSION is already set in the shell) |
| CI/CD — branch or PR | "Set VERSION" step computes <base>-<pr-or-branch>-SNAPSHOT and writes it to $GITHUB_ENV; env.sh sees it already set and skips the fallback |
CI/CD — tag v1.2.3 |
"Set VERSION" step strips the v prefix and writes VERSION=1.2.3 to $GITHUB_ENV |
To build with a specific version locally:
export VERSION=1.2.0-SNAPSHOT
source env.sh build --skip-vault
./mvnw clean packageOr as a one-liner (no shell modification):
VERSION=1.2.0-SNAPSHOT ./mvnw clean packageTo bump the base development version, update only the VERSION file — .env-build.sh and the pipeline both derive from it automatically.
Use the env.sh script to initialize with the local mode to setup the environment to run your application locally on your development machine.
source env.sh local ...Refer to nr-polaris-docs for more information on how env.sh sets up the local development runtime environment and how to customize the environment.