Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenShift Deployment

Hi I am new to open shift . I don't know how to create repository and deploying our project to it. I have configured it through command prompt. After installing rhc successfully through command prompt I am getting confusion of help given on Open Shift site regarding uploading the application not about pushing and commiting. I got the idea about commiting and pushing but I did not get the idea about deploying or uploading the application first time . Please help me I am getting stuck for a lot of time thanks in advance

like image 415
Ravi Dutt Avatar asked May 22 '13 12:05

Ravi Dutt


3 Answers

Deploying and Building Application

All OpenShift applications are built around a Git source control workflow - you code locally, then push your changes to the server. The server then runs a number of hooks to build and configure your application, and finally restarts your application. Optionally, applications can elect to be built using Jenkins, or run using "hot deployment" which speeds up the deployment of code to OpenShift.

Making Changes to your Application As a developer on OpenShift, you make code changes on your local machine, check those changes in locally, and then "push" those changes to OpenShift. One of the primary advantages of Git is that it does not require a continuous online presence in order to run. You can easily check in (in Git terminology, 'commit') and revert changes locally before deciding to upload those changes to OpenShift.

Every OpenShift application you create has its own Git repository that only you can access. If you create your application from the command line, rhc will automatically download a copy of that repository (Git calls this 'cloning') to your local system. If you create an application from the web console, you'll need to tell Git to clone the repository. Find the Git URL from the application page, and then run:

$ git clone <git_url> <directory to create>

Once you make changes, you'll need to 'add' and 'commit' those changes - 'add' tells Git that a file or set of files will become part of a larger check in, and 'commit' completes the check in. Git requires that each commit have a message to describe it.

$ git add .
$ git commit -m "A checkin to my application"

Finally, you're ready to send your changes to your application - you'll 'push' these changes with:

$ git push

The output of the push command will contain information from OpenShift about your deployment -

Source Click me

like image 67
Hidden Avatar answered Nov 09 '22 15:11

Hidden


There are two options for deploying content to the Tomcat Server within OpenShift. Both options can be used together (i.e. build one archive from source and others pre-built)

1) (Preferred) You can upload your content in a Maven src structure as is this sample project and on git push have the application built and deployed. For this to work you'll need your pom.xml at the root of your repository and a maven-war-plugin like in this sample to move the output from the build to the webapps directory. By default the warName is ROOT within pom.xml. This will cause the webapp contents to be rendered at http://app_name-namespace.rhcloud.com/. If you change the warName in pom.xml to app_name, your base url would then become http://app_name-namespace.rhcloud.com/app_name.

Note: If you are building locally you'll also want to add any output wars under webapps from the build to your .gitignore file.

Note: If you are running scaled EWS2.0 then you need an application deployed to the root context (i.e. http://app_name-namespace.rhcloud.com/) for the HAProxy load-balancer to recognize that the EWS2.0 instance is active.

or

2) You can git push pre-built wars into webapps/. To do this with the default repo you'll want to first run 'git rm -r src/ pom.xml' from the root of your repo.

Basic workflows for deploying pre-built content (each operation will require associated git add/commit/push operations to take effect):

A) Add new zipped content and deploy it:

  1. cp target/example.war webapps/

B) Undeploy currently deployed content:

  1. git rm webapps/example.war

C) Replace currently deployed zipped content with a new version and deploy it:

  1. cp target/example.war webapps/

Note: You can get the information in the uri above from running 'rhc domain show'

If you have already committed large files to your git repo, you rewrite or reset the history of those files in git to an earlier point in time and then 'git push --force' to apply those changes on the remote OpenShift server. A git gc on the remote OpenShift repo can be forced with (Note: tidy also does other cleanup including clearing log files and tmp dirs):

rhc app tidy -a appname

Whether you choose option 1) or 2) the end result will be the application deployed into the webapps directory. The webapps directory in the Tomcat distribution is the location end users can place their deployment content (e.g. war, ear, jar, sar files) to have it automatically deployed into the server runtime.

like image 7
Sumana Mehta Avatar answered Nov 09 '22 16:11

Sumana Mehta


Here is really good tutorial prepared by openshift guys with source code so you can go wrong with it. https://www.openshift.com/blogs/spring-polyglot-persistence-part-1

To sum up - if you have your application on some repository just create your application so it creates folder with git repo in your directory

rhc app create notebook jbossas-7 -l <openshift_login_email> -d

Go to newly created directory and replace default openshift code with your repo

git rm -rf src/ pom.xml

git commit -am "removed default files"

git remote add notebook -m master git://github.com/shekhargulati/notebook-part1.git

git pull -s recursive -X theirs notebook master

git push

You should see your java application build.

like image 1
pbaranski Avatar answered Nov 09 '22 15:11

pbaranski