Most developers have their public or private Git repositories. For now Git is the most popular version control system designed to handle everything from small to very large projects with speed and efficiency. Moreover it is easy to learn and has a tiny footprint with lightning fast performance. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.
There are tons of tools that help developers to manage, view and serve such repositories and Gitblit is one of the best. It is designed primarily as a tool for small workgroups who want to host centralized repositories. You can use it as a dumb repository viewer with no administrative controls or user accounts, as a complete Git stack for cloning, pushing, and repository access control. In addition Gitblit can be freely used without any other Git tooling (including actual Git) or it can cooperate with your established tools. BTW administrators can create and manage all repositories, user accounts, and teams from the web UI
Let’s look at how to run Gitblit in the cloud and simplify Java and PHP app deployment using this great tool.
Create an environment
1. Go to Jelastic.com and sign up if you haven't done it yet or log in with your Jelastic credentials by clicking the Sign In link on the page.
2. While in Jelastic dashboard, click the Create environment button.
3. In the Environment Topology dialog, pick your application server (for example, Tomcat 7). Then type your environment name, for example, gitblit.
It will take just a minute for your environment to be created.
Upload Java package
1. Navigate to gitblit.com and download Gitblit WAR file.
2. Upload your Java package to the Deployment manager.
3. Once the package is in Jelastic, deploy it to the environment you have just created.
Now you can open your app in a web browser, log in (the default credentials are admin/admin) and start using it.
Java project deployment
Let's examine how to deploy your Java project from Gitblit to the cloud in a few minutes.
1. Create your new repository.
2. As you can see your repository is successfully created.
3. Push your project to the repository you have just created, using the next scenario:
- Clone your empty repository into a newly created directory, using the next command:
git clone http://{env_name}.{hoster_domain}/{db_name}/git/{repository_name}.git
- Add your project to the newly created directory.
- Navigate to the folder you have just created and add file contents to the index, in our case we just copied simple Maven based Hello World Application:
git add .
- Record changes to the repository using for example "Initial commit" as the commit message:
git commit -m "Initial commit"
- Add your github repo as a remote to your local git repo:
git remote add gitblit http://{env_name}.{hoster_domain}/{db_name}/git/{repository_name}.git
- Push your project to your Gitblit repository:
git push gitblit master
4. Go back to the Jelastic dashboard and create a new environment for your application: pick your application server (e.g. Tomcat 7), select Maven as your building tool and type the environment name.
6. When your environment is successfully created add your project to Maven.
7. In the dialog, navigate to Git tab: specify your project name and Path to the repository, which you have created earlier, enter the Branch, Login and Password to your repository (it it's private), name of your Environment and Context in which you will deploy your project.
8. Click Buid and deploy button for your project.
9. As you can see your project was successfully built and deployed and now you can open it in a web browser.
PHP project deployment
Now it's turn for PHP project.
1. Create a new repository for your PHP project using Gitblit.
2. Push your project to the repository you have just created, using the next scenario:
- Clone your empty repository into a newly created directory, using the next command:
git clone http://{env_name}.{hoster_domain}/{db_name}/git/{repository_name.git}
- Add your project to the newly created directory.
- Navigate to the folder you have just created and add file contents to the index, in our case we just created index.php file with phpinfo() function inside:
git add .
- Record changes to the repository using for example "Initial commit" as the commit message:
git commit -m "Initial commit"
- Add your github repo as a remote to your local git repo:
git remote add gitblit http://{env_name}.{hoster_domain}/{db_name}/git/{repository_name.git}
- Push your project to your Gitblit repository:
git push gitblit master
3. As you can see your project was successfully pushed to Gitblit.
4. Go back to the Jelastic dashboard and create a new environment for your PHP application: pick Nginx (or Apache) as your application server and type the environment name.
5. Add your project to Nginx.
6. In the dialog, navigate to Git tab: specify the Path to the repository, which you have created earlier, enter the Branch, Login and Password to your repository (it it's private) and the Context in which you will deploy your project.
7. Now you can open your app in a web browser.
As you can see it's very easy to get your own online project hosting in the cloud. Manage, view, serve your repositories, then build and deploy them automatically without any code changes or additional configurations. Enjoy all the advantages of the cloud!