Showing posts with label setup. Show all posts
Showing posts with label setup. Show all posts

Saturday, 26 January 2013

Open Terminal and Execute following commands:

-------------------------------------------------------- RHC SETUP ------------------------------------------------------
STEP 1) Install Redhat Packages:

$ sudo gem install rhc

STEP 2) Setup Redhat:

$ rhc setup

STEP 3) Check the setup is properly done:

rhc domain show OR rhc app show --state

---------------------------------------------- RHC SETUP COMPLETED ----------------------------------------------



--------------------------------------------------------- EXAMPLE-----------------------------------------------------------

STEP 4) Create an application using rhc command where ever you want. Note that according to the value of the local git repository path you declare, this is where  your application will be created. This will create a project with all folder structure and other web app descriptor files.
So for example if you use the following rhc command:

$ rhc-create-app -a HelloWorld -l sunil.gulabani@indianic.com -t jbossas-7 -r HelloWorld

you will see that HelloWorld directory created at the path that was supplied with -r created. See below the content of HelloWorld directory after creation:


STEP 5) Now with maven you can easily turn this application into an eclipse application.
Switch your working directory to the folder of you new application for example

$ cd HelloWorld

Now use the following maven command in order to prepare the project for import to eclipse:

$ mvn eclipse:eclipse

Once the maven task end the project is ready to be imported into eclipse.

STEP 6) Before starting adding content removing the current pom.xml and other artifacts created at application creation is required:

$ git rm -r src pom.xml

$ git commit -m "removing artifacts from application creation phase"



STEP 7) Import the project to eclipse
We start by importing an existing project into eclipse

Now select the directory of you new application as the root:

Click next and the project will appear in you eclipse projects tree.



STEP 8) Change the project facet to Dynamic Web, Java (1.6 and above), Javascript

Changing the project facet is just a matter of few clicks:
- Right click on your project and select properties.
- Select Project Facets (press convert to allowing facets to be defined for you project as eclipse suggests).

- Click ok. You project now is configured in eclipse as Dynamic Web Project which is more convenient for later common web app tasks.

- Now lets add a simple jsp file to the project before commiting and deploying to openshift express.

- Just right click on the project and select New–>jspFile (as the project facet is dynamic web app new jsp is available and will be placed under the WebContent folder the same will be available with other web resources like servlets).
    - Now its time to commit and deploy to openshift.

STEP 9) Creating a war file The easiest way to package the project into a war via eclipse export option so just right click on the project and export as HelloWorld.war into the HelloWorld/deployments folder of the application.

STEP 10) From console: Add to your openshift git commit and push
Now that you have a war file ready for deployment (HelloWorld/deployments/HelloWorld.war) lets add it to the git repository and then commit and finally we will push the war to the openshift express instance.
Open a terminal window and switch the working directory to the application’s deployments directory then execute the following commands:

$ cd deployments/

$ git add HelloWorld.war

$  git commit -m "depolying myapp application" HelloWorld.war

$ git push

Note that git repository is created at the root project level so all files can be added to git and not only the deployment.

STEP 11) Your push completed and you application should be available at the following openshift URL:

http://helloworld-jsr10.rhcloud.com/HelloWorld/index.jsp
Step 1:  Install Eclipse

Point your browser at the eclipse download page and select the installation package for your needs.  For this blog post, I will be using the Eclipse IDE for Java Developers package.


After downloading eclipse, extract the archive and you will have an eclipse directory.  Inside of this directory, you will have an Eclipse executable that will start the IDE.



Step 2: Install JBoss Tools

Once you have Eclipse up and running, the next step is to install the JBoss Tools package that provides the OpenShift integration.  You can install JBoss Tools from the Eclipse marketplace. Make sure that the version of JBoss Tools that you are using matches the version of Eclipse that you are using (Indigo, Juno, etc.).



Expand JBoss Tools and select JBoss OpenShift Tools.



Once the JBoss OpenShift tools have been installed, you will need to restart Eclipse.



Step 3:  Create an OpenShift Project

Now that we have the toolset installed, it’s time to create our cloud project and begin development.  Select File -> New -> Other -> Expand OpenShift -> OpenShift Application and click Next.





Before you can start creating and deploying your projects, you will need to authenticate with the OpenShift web services via the dialog provided.



If you do not already have an OpenShift account, click the signup button or head on over to the OpenShift web site and create a new account.

After creating your account, you will also need to specify a domain that you want to use for your applications.  The domain is used to create the unique URL for your running application with the following template:
applicationName-domainName.rhcloud.com.
The domain you select will be used for all of your deployed applications on the Red Hat Cloud.

Once you have successfully authenticated to the OpenShift web services, you will be presented with the Setup OpenShift Application Wizard.  The dialog provides the following functionality:
  • Use an existing application that is already deployed on your OpenShift account
  • View details for existing application
  • Create new application
  • Add cartridges to your application
  • Specify your gear size (Small / Medium / Large)
  • Enable scaling for your application


Note: We will be creating a new application, if you want to continue development on an existing application, select use an existing application and click browse.  This will create a new Eclipse project and perform a git clone on your existing git repository.

In order to create a new application, give your application a name and select which cartridge or application server that your deployment will target.  At the time of this writing, OpenShift provides support for JBoss AS 7, PHP, perl, ruby, python, node.js, and diy.



Step 4: Configure your ssh keys

In order to communicate via git to your repository, we need to configure our ssh keys.  If this is the first time you have used OpenShift, and go through the domain creation wizard, a key will be created and automatically uploaded for you.

If you are an existing OpenShift user, we will need to use your existing key or create a new one.  Fortunately, we provide a UI to accomplish this task as well. Click the SSH2 Preferences link provided in order to create your keys.


If you don’t have a ssh key created on your machine, select the Key Management tab -> Generate RSA Key.  Provide a passphrase if you desire and then click Save Private Key.  You will also want to copy your public key that is displayed so that we can add it to OpenShift.



Now that you have a key pair generated, we need to tell OpenShift what our public key is.  Login to OpenShift website, click Manage your Apps, click on My Account, and select to Add a new key.


Give your new key a name of JBossTools and paste the key into the textfield provided.




Step 5: Clone your repo

After creating and publishing your public ssh key to OpenShift, we are ready to clone our repo and begin development.  Switch back over to your Eclipse IDE and click the finish button.  This will create your project and clone the private git repository that lives on the OpenShift servers.

Step 6: Code
This is what you love to do.

Step 7: Update maven configuration
You may notice an error marker next your project after you have cloned your git repository.  This is easily fixed by updating your maven project configuration.  Right click on your project, select maven, and then update project configuration.

Step 8: Deploy your code to the cloud

Once you have modified some of your source files, click the server tab at the bottom of the screen.  You should see your OpenShift application listed.  In order to push your changes live, right click on your application and select publish.

Once the push process is complete, point your browser to applicatonName-namespace.rhcloud.com
and you should see your brand new application deployed on the cloud.
Find me on Facebook! Follow me on Twitter!