Exporting an app for production

This page has everything you need to know about exporting your app from the BladeRunner development environment, to your production environment.

BladeRunner apps use Java Enterprise Edition (JEE) as a production environment, and this tutorial will guide you through creating a war file (Web application Archive) that is ready to be deployed.

What’s the Difference Between the Development App and the Production war?

Bundlers

During development, bundlers do their dependency analysis and concatenation work on demand, because you are constantly changing your codebase. In the production environment this is no longer the case, so we can output each bundle to a single file when the war in generated. When the war is deployed to a production environment, the files created are simply served as they are.

Minifiers

Minifiers are not usually used during development as they slow down the page load time and make debugging harder. They are employed in production to ensure fast loading time and some source code protection. There are four minification settings available: 'default', 'closure-whitespace', 'closure-simple' and 'closure-advanced', where 'default' is a simple concatenator well suited for use in development, rather than an actual minifier. It’s possible to debug your application with minification enabled by editing 'conf/bladerunner.conf' and pointing 'default' to one of the real minifier classes.

GZipping

The generated bundles used in production mode are GZipped when the war is created, to increase the download speed of the app, while also placing no load on the server. The image bundle is omitted from the GZipping as images have already been compressed.

Ensure All Environmental Properties Are Parameterised

Make sure that you have parameterised any properties for database URLs, server locations and anything else that differs from one environment to another.

The Configure my app for different environments section tells you how to do this.

Export a war file

There are two ways that you can export your application to a war file: either via the command line, or by using the interface provided in the BladeRunner Dashboard.

From the Command Line

From the command line, enter the following instruction:

bladerunner war <app-name> [target-war-location] [-m <minifier>]

For example:

bladerunner war myapp C:\output_dir\prod.war -m closure-simple

This will output the myapp application in a file called prod.war.

Omitting a target filename will result in the war file taking the name of the original app. You could also omit the location altogether, which will result in the war file being saved in the bladerunner/sdk/ folder.

Omitting a minifier value will result in the minification setting of 'default' being used.

From the BladeRunner Dashboard

br gs export war 1

Go to the Dashboard in your browser, and select the app you want to export, as shown in the screenshot above, and then click the "Export WAR" button.

Prep Your JEE Server

Create all the JNDI environment variables in your app server, ready for your war file. Have a look at the files $APP_ROOT/WEB-INF/jetty-env.xml for environment variables, and $APP_ROOT/WEB-INF/web.xml for any other configuration that your app expects the Application Server to provide.

Follow your Application Server’s guide on how to set these up. For Tomcat 6.0, these details can be found at http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html

Deploy your war

Follow your Application Server’s guide on how to deploy your war. Your app should now work in the same way as it did on the development environment, but…​

  • As all the configuration details are stored outside of the war file, you can use the same war file for all your environments. Reducing deployment risk

  • You’ll probably want to get your Continuous Integration Process to run the war task automatically.