Specifying your own template Git repository URL
In the Creating an OpenShift application using the rhc command-line client recipe, we created an application that used a template source code provided by OpenShift. Let's suppose you want OpenShift to use your Git repository to populate the initial contents of the application. This can be accomplished using the --from-code
option at application creation time.
Getting ready
To complete this recipe, you will need the rhc command-line client installed on your machine. Please refer to the Installing the OpenShift rhc command-line client recipe in Chapter 1, Getting Started with OpenShift, for details. You should also complete the setup on your OpenShift account using rhc by following the Setting up an OpenShift account using rhc recipe in Chapter 1, Getting Started with OpenShift.
How to do it…
To create an application that uses initial content from your own Git repository, use the--from-code
option:
$ rhc create-app javaapp jbosseap-6 --from-code https://github.com/OpenShift-Cookbook/chapter3-recipe2.git
Note
The Git repository URL should be a public Git repository; otherwise, application creation will fail as OpenShift cannot access the repository.
How it works…
When you create an OpenShift application using the --from-code
option, the OpenShift server will first clone the Git repository provided with the --from-code
option and then use that repository source code to populate the initial contents of the application. The Git repository URL should be a public Git repository; otherwise, OpenShift will not be able to clone the repository and will instead raise an exception. Following this, OpenShift will build the source code, create an artifact, and then deploy the artifact to the server. An artifact is a by-product produced during the development of software, for example, in the case of Java applications, it could be either a Java Archive (JAR), Web Archive (WAR), or Enterprise Archive (EAR) file.
In the previous command, we created a JBoss EAP application that used a public Git repository URL as its initial code. After the application is successfully created, you can view the application running at http://javaapp-{domain-name}.rhcloud.com/
. The application is a simple demonstration of the article extraction library called Boilerpipe (which you can access at https://code.google.com/p/boilerpipe/). It takes a URL and gives you the title and relevant text from the URL.
See also
- The Creating a WordPress application using the web console recipe in Chapter 1, Getting Started with OpenShift
- The Creating an OpenShift application using the rhc command-line client recipe