Skip to content
Snippets Groups Projects
Select Git revision
  • 1539d646cf9f5de5d5819b51670a0020e49b11fd
  • master default protected
2 results

jetty

user avatar
Erik Hedenström authored
1539d646
History
Name Last commit Last update
.dockerignore
Dockerfile
README.md
init.sh

Jetty - Jetty, Exim, and MySQL stack

Building

docker build --rm -t registry.codemate.se/jetty .

Usage

It's as simple as:

docker pull registry.codemate.se/jetty
docker run -d registry.codemate.se/jetty

Customize exposed port

By default, the port 8080 (jetty) is mapped to a random port on the docker host. To customize, run:

docker run -p 8080:8080 -d registry.codemate.se/jetty

More info about port redirection can be found in the official Docker documentation.

Persist application data on the docker host

Jetty is configured to scan /opt/app/webapps when starting. To persist data to the docker host simply map a host directory to /opt/app. In the host directory create a webapps folder where place war, xml, or exploded webapps.

MySQL is configured to store data files in '/opt/app/mysql-data' which will also cause it to be persisted to the host.

docker run -v /data/jetty-demo-app:/opt/app -d registry.codemate.se/jetty

Running a different Jetty version

By default, the container downloads and installs Jetty 9.2.2.v20140723 on the first boot. To specify which version to install, set the environment variable JETTY_VERSION:

docker run -e JETTY_VERSION=9.2.2.v20140723 -d registry.codemate.se/jetty

Overriding Jetty files

By providing an environment variable name JETTY_OVERLAY that points to a directory or URL of a gzipped tar file you can apply an overlay on the Jetty installation. A directory will be recursively copied, and a tarball will be unzipped and extracted in the root of the Jetty installation directory. The overlay enables you to add custom Jetty configurations.

docker run -e JETTY_OVERLAY=http://10.0.0.1/jetty-config.tgz -d registry.codemate.se/jetty
docker run -e JETTY_OVERLAY=/opt/app/jetty-config -d registry.codemate.se/jetty

The overlay is fetched using curl so file URLs are valid:

JETTY_OVERLAY="file:////opt/app/jetty-config,tgz"

If you need to provide basic auth credentials simply prefix the url with the credentials, for example:

JETTY_OVERLAY="-u username:password http://10.0.0.1/jetty-config.tgz"

Initializing MySQL

By providing an environment variable name MYSQL_INIT that points to an SQL script you initialize the MySQL database.

docker run -e MYSQL_INIT=http://10.0.0.1/jetty-init.sql -d registry.codemate.se/jetty

Basic auth credentials and file URLs can be used as mentioned in the overlay section.

Combined options

The following example shows the options we use to start a client site:

docker run \
  --name ethbutik
  -e JAVA_OPTIONS="-javaagent:/opt/app/lib/spring-agent-2.5.6.jar -Djavamonitor.uniqueid=10" \
  -e EXIM=yes \
  -v $DIR:/opt/app \
  -p 8080:8080 \
  -d registry.codemate.se/jetty

Directories

  • /opt/jetty-distribution-$JETTY_VERSION - Jetty installation directory
  • /opt/app/webapps - Directory deployer monitors for webapps
  • /opt/app/mysql-data - MySQL data.

Variables

  • JETTY_VERSION - The version to install an run (default 9.2.2.v20140723)
  • JETTY_OVERLAY - Jetty installation overlay
  • JAVA_OPTIONS - Jetty java options
  • MYSQL_INIT - MySQL init script
  • MYSQL - yes/no flag to enable MySQL (default is no)
  • EXIM - yes/no flag to enable Exim (default is no)

Exposed ports

  • 25 - Exim SMTP
  • 3306 - MySQL
  • 8080 - Jetty