Book Image

OpenShift Cookbook

By : Shekhar Gulati
Book Image

OpenShift Cookbook

By: Shekhar Gulati

Overview of this book

Table of Contents (19 chapters)
OpenShift Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Running OpenShift on a Virtual Machine
Index

Cloning the application to the local machine


Every OpenShift application has a private Git repository that houses the application source code. OpenShift uses Git not only as a version control system but also to build and deploy the application using Git's action hooks. In this recipe, you will learn how to get the source code of the OpenShift application on your local machine.

Getting ready

You will need Git installed on the operating system before stepping through this recipe. For Debian-based Linux distributions, you can install Git with apt-get install git as the root. If you are on Fedora or any other Red Hat-based system, you can install Git with yum install git-core as the root. Mac and Windows users can download the Git package from the official download site at http://git-scm.com/downloads.

This recipe will use the WordPress application created in the Creating a WordPress application using the web console recipe.

How to do it…

Perform the following steps to clone the repository:

  1. Go to the Applications tab in the web console at https://openshift.redhat.com/app/console/applications and click on the application to view its details, as shown in the following screenshot:

  2. Copy the Git repository URL mentioned on the application detail web page, as shown in the following screenshot:

  3. Open a command-line terminal, go to a convenient location on your machine, and execute the git clone command. Replace the repository URL with your application Git URL:

    $ git clone ssh://[email protected]/~/git/blog.git/
    

How it works…

The first and second steps helped us to locate the application Git repository URL. As discussed in the preceding section, OpenShift uses Git as revision control and a source code management system. Every application has a private Git repository. A Git repository contains all the information needed to retain and manage the revisions and history of a project. OpenShift uses the SSH transport protocol to work with Git repositories. To create a secure communication channel between the local machine and application gear, Git uses the SSH key setup discussed in the Uploading SSH keys using the web console recipe. Nobody will be able to clone your application repository unless you add their public SSH key to your account.

In step 3, you cloned the application Git repository using the clone command. The git clone command created a new Git repository based on the original application repository URL. The difference between Git and other version control systems is that Git clones the full copy of the repository, in addition to the working copy, of all the files in the repository. The clone command will create a new directory on your local filesystem with the same name as the application.

There's more…

You can also specify a different folder name with the git clone command. Suppose you want to clone the application in the myapp folder. To do this, execute the following command:

$ git clone ssh://[email protected]/~/git/blog.git/ myapp

If you want to allow any of your friends or team members to clone your repository, just add their public key to your account. Follow the Uploading SSH keys using the web console recipe to upload the public SSH key. We will discuss team collaboration in detail in Chapter 2, Managing Domains.

See also

  • The Deploying your first change recipe