Skip to end of metadata
Go to start of metadata

Egy ideje elérhető az OpenShift PaaS lehetőség a RedHat oldalain, amelyet ingyen ki lehet próbálni: https://openshift.redhat.com

A regisztráció után egy pár lépésből álló varázslóval ki tudjuk választani a nekünk szükséges szolgáltatásokat:

Hozzuk létre a szolgáltatásunk domain nevét:

A Create Application gombra kattintva kisvártatva (esetleg néhány perc múlva) megjelenik a konzol, illetve megnézhetjük a hivatkozott link alatt az elindított platformot: http://cloudtest-javaforum.rhcloud.com/

Ezzel a cloud létrehozásának hosszadalmas folyamata véget is ért, töltsük le és telepítsük a RedHatCloud (rhc) alkalmazását, amelyhez a Getting Started oldalon találunk útmutatást, majd nézzük meg, hogy jól működik-e a telepített kliens alkalmazás, ezért válaszoljunk a feltett kérdésekre:

$ rhc help

Starting Interactive Setup for OpenShift's command line interface

It looks like you have not configured or used OpenShift client tools on this computer. We'll help you configure the client tools with a few quick questions. You can skip this in the future by copying your configuration files to other machines you use to manage your OpenShift account:

/home/auth.gabor/.openshift/express.conf
/home/auth.gabor/.ssh/

To connect to openshift.redhat.com enter your OpenShift login (email or Red Hat login id): auth.gabor@javaforum.hu
Password: ************

Created local config file: /home/auth.gabor/.openshift/express.conf
The express.conf file contains user configuration, and can be transferred to different computers.

No SSH keys were found. We will generate a pair of keys for you.

    Created: /home/auth.gabor/.ssh/id_rsa.pub


Your public ssh key must be uploaded to the OpenShift server.  Would you like us to upload it for you? (yes/no) yes

You can enter a name for your key, or leave it blank to use the default name. Using the same name as an existing key will overwrite the old key.

Current Keys:
    None


Since you do not have any keys associated with your OpenShift account, your new key will be uploaded as the default key

Sending new key default .. Success

We will now check to see if you have the necessary client tools installed.

Checking for git ... found

Checking for your namespace ... found namespace:
    javaforum

Checking for applications ... found
    * cloudtest - http://cloudtest-javaforum.rhcloud.com/

The OpenShift client tools have been configured on your computer.  You can run this setup wizard at any time by using the command 'rhc setup' We will now execute your original command (rhc help)


Usage: rhc (<resource> | --help) [<command>] [<args>]
Command line tool for performing operations related to your rhcloud account.

List of resources
  domain             Manage the namespace for the registered rhcloud user.
  app                Manage applications within the rhcloud account.
  sshkey             Manage multiple keys for the registered rhcloud user.
  port-forward       Forward remote ports to the workstation
  server             Display information about the status of the service.
  setup              Run the setup wizard to configure your account.

See 'rhc <resource> --help' for more applicable commands and argumments on a specific resource.

Ne hezitáljunk sokat, kérdezzük le a platform jellemzőit:

$ rhc domain show
Password: ************


User Info
=========
Namespace: javaforum
  RHLogin: auth.gabor@javaforum.hu


Application Info
================
cloudtest
    Framework: jbossas-7
     Creation: 2012-07-05T15:15:32-04:00
         UUID: 03ab18978225420f881671b5b9e31e52
      Git URL: ssh://03ab18978225420f881671b5b9e31e52@cloudtest-javaforum.rhcloud.com/~/git/cloudtest.git/
   Public URL: http://cloudtest-javaforum.rhcloud.com/

 Embedded: 
      None

A megadott Git URL alatt megtaláljuk a demó alkalmazásunk forráskódját:

$ git clone ssh://03ab18978225420f881671b5b9e31e52@cloudtest-javaforum.rhcloud.com/~/git/cloudtest.git/
Initialized empty Git repository in /home/auth.gabor/cloudtest/.git/
The authenticity of host 'cloudtest-javaforum.rhcloud.com (184.72.83.237)' can't be established.
RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'cloudtest-javaforum.rhcloud.com,184.72.83.237' (RSA) to the list of known hosts.
remote: Counting objects: 39, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 39 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (39/39), 19.52 KiB, done.
Resolving deltas: 100% (1/1), done.
$ cd cloudtest/
[auth.gabor@javaforum cloudtest]$ ls -l
total 20
drwxr-xr-x. 2 auth.gabor users 4096 Jul  5 21:51 deployments
-rw-r--r--. 1 auth.gabor users 1707 Jul  5 21:51 pom.xml
-rw-r--r--. 1 auth.gabor users 7629 Jul  5 21:51 README
drwxr-xr-x. 3 auth.gabor users 4096 Jul  5 21:51 src

Nézzünk bele a pom.xml állományba:

pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>cloudtest</groupId>
  <artifactId>cloudtest</artifactId>
  <packaging>war</packaging>
  <version>1.0</version>
  <name>cloudtest</name>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-6.0</artifactId>
      <version>1.0.0.Final</version>
      <type>pom</type>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <profiles>
    <profile>
     <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
     <!-- Use this profile for any OpenShift specific customization your app will need. -->
     <!-- By default that is to put the resulting archive into the 'deployments' folder. -->
     <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
     <id>openshift</id>
     <build>
        <finalName>cloudtest</finalName>
        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
              <outputDirectory>deployments</outputDirectory>
              <warName>ROOT</warName>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

Szimpla webalkalmazásnak néz ki, hozzunk létre egy helloworld.jsp állományt, és írjuk bele a klasszikus szavakat:

src/main/webapp/helloworld.jsp
Hello World! :)

A létrehozott fájlt adjuk hozzá a feltöltendő módosításokhoz:

$ git add src/main/webapp/helloworld.jsp
$ git commit -m "Hello World message"
[master cb9e8ff] Hello World message
[...]
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 src/main/webapp/helloworld.jsp

Majd toljuk fel a változást és lepődjünk meg, ugyanis a push során néhány action_hook hatására a távoli oldalon megtörténik a build folyamat, illetve sikeres build után a deploy:

$ git push
Counting objects: 10, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 480 bytes, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Stopping application...
remote: Done
remote: ~/git/cloudtest.git ~/git/cloudtest.git
remote: ~/git/cloudtest.git
remote: Running .openshift/action_hooks/pre_build
remote: Found pom.xml... attempting to build with 'mvn -e clean package -Popenshift -DskipTests'
remote: Apache Maven 3.0.3 (r1075437; 2011-06-20 13:22:37-0400)
remote: Maven home: /etc/alternatives/maven-3.0
remote: Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
remote: Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
remote: Default locale: en_US, platform encoding: UTF-8
remote: OS name: "linux", version: "2.6.32-279.el6.x86_64", arch: "i386", family: "unix"
remote: [INFO] Scanning for projects...
remote: [INFO]                                                                         
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Building cloudtest 1.0
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] 
remote: [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ cloudtest ---
remote: [INFO] 
remote: [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ cloudtest ---
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] Copying 1 resource
remote: [INFO] 
remote: [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ cloudtest ---
remote: [INFO] Nothing to compile - all classes are up to date
remote: [INFO] 
remote: [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ cloudtest ---
remote: [INFO] Using 'UTF-8' encoding to copy filtered resources.
remote: [INFO] skip non existing resourceDirectory /var/lib/stickshift/03ab18978225420f881671b5b9e31e52/app-root/runtime/repo/src/test/resources
remote: [INFO] 
remote: [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ cloudtest ---
remote: [INFO] No sources to compile
remote: [INFO] 
remote: [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ cloudtest ---
remote: [INFO] Tests are skipped.
remote: [INFO] 
remote: [INFO] --- maven-war-plugin:2.1.1:war (default-war) @ cloudtest ---
remote: [INFO] Packaging webapp
remote: [INFO] Assembling webapp [cloudtest] in [/var/lib/stickshift/03ab18978225420f881671b5b9e31e52/app-root/runtime/repo/target/cloudtest]
remote: [INFO] Processing war project
remote: [INFO] Copying webapp resources [/var/lib/stickshift/03ab18978225420f881671b5b9e31e52/app-root/runtime/repo/src/main/webapp]
remote: [INFO] Webapp assembled in [214 msecs]
remote: [INFO] Building war: /var/lib/stickshift/03ab18978225420f881671b5b9e31e52/app-root/runtime/repo/deployments/ROOT.war
remote: [INFO] WEB-INF/web.xml already added, skipping
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD SUCCESS
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 30.692s
remote: [INFO] Finished at: Thu Jul 05 15:59:43 EDT 2012
remote: [INFO] Final Memory: 6M/163M
remote: [INFO] ------------------------------------------------------------------------
remote: Running .openshift/action_hooks/build
remote: Emptying tmp dir: /var/lib/stickshift/03ab18978225420f881671b5b9e31e52/cloudtest/jbossas-7/standalone/tmp/auth
remote: Emptying tmp dir: /var/lib/stickshift/03ab18978225420f881671b5b9e31e52/cloudtest/jbossas-7/standalone/tmp/vfs
remote: Emptying tmp dir: /var/lib/stickshift/03ab18978225420f881671b5b9e31e52/cloudtest/jbossas-7/standalone/tmp/work
remote: Syncing Git deployments directory [/var/lib/stickshift/03ab18978225420f881671b5b9e31e52/app-root/runtime/repo//deployments/] with JBoss deployments directory [/var/lib/stickshift/03ab18978225420f881671b5b9e31e52/cloudtest/jbossas-7/standalone/deployments/]
remote: sending incremental file list
remote: deleting ROOT.war.deployed
remote: .gitkeep
remote: ROOT.war
remote: 
remote: sent 9968 bytes  received 50 bytes  20036.00 bytes/sec
remote: total size is 9824  speedup is 0.98
remote: Running .openshift/action_hooks/deploy
remote: Starting application...
remote: Done
remote: Running .openshift/action_hooks/post_deploy
To ssh://03ab18978225420f881671b5b9e31e52@cloudtest-javaforum.rhcloud.com/~/git/cloudtest.git/
   9977015..ce88d1e  master -> master

Az eredmény nem marad el: http://cloudtest-javaforum.rhcloud.com/helloworld.jsp

Kellemes próbálgatást... (smile)

      
      
Page viewed times
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))