From 9712a4e386e12409e7c78cb205f27aa77dbfa837 Mon Sep 17 00:00:00 2001 From: Vineet Reynolds Date: Thu, 27 Nov 2014 18:28:23 +0530 Subject: [PATCH] Removed OpenShift binary deployment info. Added instructions to perform the Maven build on OpenShift instead. --- demo/README.md | 115 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 27 deletions(-) diff --git a/demo/README.md b/demo/README.md index 3e7409d34..5bfcd699d 100644 --- a/demo/README.md +++ b/demo/README.md @@ -93,39 +93,100 @@ You can run TicketMonster into a local JBoss EAP 6.3 instance or on OpenShift. #### Create an OpenShift project -1. Make sure that you have an OpenShift domain and you have created an application using the `jbosseap-6` cartridge (for more details, get started [here](https://openshift.redhat.com/app/getting_started)). If you want to use PostgreSQL, add the `postgresql-9.2` cartridge too. Or, if you want to use MySQL, add the `mysql-5.5` cartridge. -2. Ensure that the Git repository of the project is checked out. +> The following variables are used in these instructions. Be sure to replace them as follows: +* APP_NAME should be replaced with the name of the application you create on OpenShift. +* YOUR_DOMAIN_NAME should be replaced with the OpenShift domain name. +* APPLICATION_UUID should be replaced with the UUID generated by OpenShift for your application, for example: 52864af85973ca430200006f +* TICKETMONSTER_MAVEN_PROJECT_ROOT is the location of the Maven project sources for the TicketMonster application. -#### Building and deploying +1. Open a shell command prompt and change to a directory of your choice. Enter the following command to create a JBoss EAP 6 application: -1. Build TicketMonster using either: - * the default profile (with H2 database support) - - mvn clean package - * the `postgresql-openshift` profile (with PostgreSQL support) if the PostgreSQL cartrdige is enabled in OpenShift. - - mvn clean package -Ppostgresql-openshift - * the `mysql-openshift` profile (with MySQL support) if the MySQL cartrdige is enabled in OpenShift. - - mvn clean package -Pmysql-openshift - -2. Copy the `target/ticket-monster.war`file in the OpenShift Git repository(located at ``). + rhc app create -a APP_NAME -t jbosseap-6 - cp target/ticket-monster.war /deployments/ROOT.war + This command creates an OpenShift application named APP_NAME and will run the application inside the jbosseap-6 container. You should see some output similar to the following: -3. Navigate to `` folder -4. Remove the existing `src` folder and `pom.xml` file. + Application Options + ------------------- + Domain: YOUR_DOMAIN + Cartridges: jbosseap-6 (addtl. costs may apply) + Gear Size: default + Scaling: no + + Creating application 'APP_NAME' ... done + + + Waiting for your DNS name to be available ... done + + Cloning into 'APP_NAME'... + Warning: Permanently added the RSA host key for IP address '54.90.10.115' to the list of known hosts. + + Your application 'APP_NAME' is now available. + + URL: http://APP_NAME-YOUR_DOMAIN.rhcloud.com/ + SSH to: APPLICATION_UUID@APP_NAME-YOURDOMAIN.rhcloud.com + Git remote: ssh://APPLICATION_UUID@APP_NAME-YOUR_DOMAIN.rhcloud.com/~/git/APP_NAME.git/ + Cloned to: /Users/vineet/openshiftapps/APP_NAME + + Run 'rhc show-app APP_NAME' for more details about your app. - git rm -r src - git rm pom.xml +2. The create command creates a git repository in the current directory with the same name as the application. -5. Add the copied file to the repository, commit and push to Openshift - - git add deployments/ROOT.war - git commit -m "Deploy TicketMonster" - git push + You do not need the generated default application, so navigate to the new git repository directory created by the OpenShift command and tell git to remove the source and pom files: + + cd APP_NAME + git rm -r src pom.xml + +3. Copy the TicketMonster application sources into this new git repository: + + cp -r TICKETMONSTER_MAVEN_PROJECT_ROOT/src . + cp -r TICKETMONSTER_MAVEN_PROJECT_ROOT/pom.xml . + +#### Use MySQL as the database + +1. Add the MySQL 5.5 cartridge to the `ticketmonster` application: + + rhc cartridge add mysql-5.5 -a ticketmonster + +2. Configure the OpenShift build process, to use the `mysql-openshift` profile within the project POM. To do so, create a file named `pre_build_jbosseap` under the `.openshift/action_hooks` directory located in the git repository of the OpenShift application, with the following contents: + + export MAVEN_ARGS="clean package -Popenshift,mysql-openshift -DskipTests" + +3. Set the executable bit for the action hook: + + chmod +x TICKET_MONSTER_OPENSHIFT_GIT_REPO/.openshift/build_hooks/pre_build_jbosseap + + On Windows, you will need to run the following command to set the executable bit to the `pre_build_jbosseap` file: + + git update-index --chmod=+x .openshift/build_hooks/pre_build_jbosseap + +#### Use PostgreSQL as the database + +1. Add the PostgreSQL 9.2 cartridge to the `ticketmonster` application: + + rhc cartridge add postgresql-9.2 -a ticketmonster + +2. Configure the OpenShift build process, to use the `postgresql-openshift` profile within the project POM. To do so, create a file named `pre_build_jbosseap` under the `.openshift/action_hooks` directory located in the git repository of the OpenShift application, with the following contents: + + export MAVEN_ARGS="clean package -Popenshift,postgresql-openshift -DskipTests" + +3. Set the executable bit for the action hook: + + chmod +x TICKET_MONSTER_OPENSHIFT_GIT_REPO/.openshift/build_hooks/pre_build_jbosseap + + On Windows, you will need to run the following command to set the executable bit to the `pre_build_jbosseap` file: + + git update-index --chmod=+x .openshift/build_hooks/pre_build_jbosseap + +#### Deploying to OpenShift + +1. You can now deploy the changes to your OpenShift application using git as follows: + + git add src pom.xml + git commit -m "TicketMonster on OpenShift" + git push -6. Now you can see the application running at `http://-.rhcloud.com` + The final push command triggers the OpenShift infrastructure to build and deploy the changes. -_NOTE: this version of TicketMonster uses the *binary* deployment style._ + Note that the `openshift` profile in pom.xml is activated by OpenShift, and causes the WAR build by OpenShift to be copied to the deployments/ directory, and deployed without a context path. + Now you can see the application running at http://APP_NAME-YOUR_DOMAIN.rhcloud.com/.