Skip to content

Latest commit

 

History

History
203 lines (133 loc) · 5.63 KB

File metadata and controls

203 lines (133 loc) · 5.63 KB

Build and Deploy Java EE Application

Now that you learned a lot about images, containers and how to link them together, it is about time to learn about the different deployment options. Let’s start over with the Ticket Monster applications again. Ticket Monster is a moderately complex application that demonstrates how to build modern applications using JBoss web technologies.

Build Application

We’re going to build the application first.

  1. Clone the repo:

$ cd /root

$ git clone https://github.com/jboss-developer/ticket-monster.git
  1. Build the application:

$  cd ticket-monster/demo

$  mvn clean package

Start Application Server

Create a folder to place the deployments and give it write access

$ mkdir /deployments
$ chmod 777 /deployments
$ chcon -Rt svirt_sandbox_file_t /deployments

Start WildFly server as:

$ docker run --name wildfly -d -p 8080:8080 -v /deployments:/opt/jboss/wildfly/standalone/deployments/:rw jboss/wildfly

This command starts a container named “wildfly”.

The -v flag maps a directory from the host into the container. This will be the directory to put the deployments. rw ensures that the Docker container can write to it.

Check logs to verify if the server has started.

$ docker logs -f wildfly

Access http://<external-ip>:8080 in your browser to make sure the instance is up and running.

Now you’re ready to deploy the application for the first time.

Copy the geneated WAR to your deploy folder.

$ cp target/ticket-monster.war /deployments

Congratulations!

You’ve deployed your first application to WildFly running in a Docker container from JBoss Developer Studio. You can check it by looking in the logs or accessing http://<external-ip>:8080/ticket-monster/

Stop WildFly container when you’re done.

$ docker stop wildfly
$ docker rm wildfly

Deploy Application Using CLI

WildFly

  1. Download WildFly 10.0.0.Final from Internet: http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip .

  2. Install it by extracting the archive.

$ cd /root
$ wget http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip
$ unzip wildfly-10.0.0.Final.zip
$ cd wildfly-10.0.0.Final/bin/

CLI

The Command Line Interface (CLI) is a tool for connecting to WildFly instances to manage all tasks from command line environment. Some of the tasks that you can do using the CLI are:

  1. Deploy/Undeploy web application in standalone/Domain Mode.

  2. View all information about the deployed application on runtime.

  3. Start/Stop/Restart Nodes in respective mode i.e. Standalone/Domain.

  4. Adding/Deleting resource or subsystems to servers.

Lets use the CLI to deploy ticket-monster to WildFly running in the container.

  1. CLI needs to be locally installed and comes as part of WildFly.

  2. Run the “wildfly-management” image with fixed port mapping as explained in [Management_Fixed_Port_Mapping].

  3. Run the jboss-cli command and connect to the WildFly instance.

Start WildFly server as:

$ docker run --name wildfly-managed -d -p 8080:8080 -p 9990:9990 rafabene/wildfly-admin

This command starts a container named “wildfly-managed”.

$ ./jboss-cli.sh --controller='localhost:9990'  -u='admin' -p='docker#admin' -c

This will show the output as:

[standalone@localhost:9990 /]
  1. Deploy the application as:

deploy /root/ticket-monster/demo/target/ticket-monster.war --force

exit
  1. Stop Wildfly

$ docker stop wildfly-managed
$ docker rm wildfly-managed

Now you’ve sucessfully used the CLI to remote deploy the Ticket Monster application to WildFly running as docker container.