Skip to content

Deploying to a Production Server

Steve Hannah edited this page Jul 28, 2016 · 1 revision

Generally, you’ll want to test your apps locally, and deploy to a production server (somewhere in the cloud) for every release so that the world can enjoy your app.

You’ll always need at least some configuration settings to be different between the debug/local and production/remote deployments. For example, at the very least, your client app will have to be configured to connect to a different host for the web service. Other common differences may involve database connection configuration.

This template allows you to maintain separate configurations for production and local deployment. There are number of "runtime" properties files in the template that allow you to configure runtime settings in both the client and server apps.

Steves-iMac:spring-contacts shannah$ find . | grep runtime | grep -v target | grep -v build
./client/runtime.local.properties
./client/runtime.local.properties.sample
./client/runtime.production.properties
./client/src/runtime.properties
./server/runtime.local.properties.sample
./server/runtime.production.properties
./server/src/main/resources/runtime.properties

Client Runtime Properties

The client/src/runtime.properties file contains the default client runtime properties. You can define local-only properties in your client/runtime.local.properties file. These will be applied to the app when you build any of the local build targets (build-local-simulator, build-local-android, build-local-ios). You can also define production-only properties in your client/runtime.production.properties file. These will be applied to the app when you build any of the production targets (build-production-simulator, build-production-android, build-production-ios).

Note
I have been asked why we include a build-production-simulator target, when you’re not going to be distributing the simulator app. This is to allow you to test your client app against the production server inside the simulator. Even though you’re not actually going to distribute the simulator build, it is helpful for debugging the production app.

Server Runtime Properties

The server/src/runtime.properties file contains the default server runtime properties. You can define local-only properties in your server/runtime.local.properties file. These will be applied to the app when you build the build-local-webservice target. You can also define production-only properties in your server/runtime.production.properties file. These will be applied to the app when you build the build-production-webservice target.

Deploying WAR to Server

Once you have your configuration settings ready for your production server, you simply run the build-production-webservice target:

$ ant build-production-webservice

This will build the server project, and the result will be saved as a WAR file inside your server/target directory. You can copy this .war file to your production server.