Giter Site home page Giter Site logo

openshift-diy-spring-boot-sample's Introduction

Prerequisite

Before we can start building the application, we need to have an OpenShift free account and client tools installed.

Step 1: Create DIY application

To create an application using client tools, type the following command:

rhc app create boot diy-0.1

This command creates an application boot using DIY cartridge and clones the repository to boot directory.

Step 2: Add PostgreSQL cartridge to application

The application we are creating will use PostgreSQL database, hence we need to add appropriate cartridge to the application:

rhc cartridge add postgresql-9.2 --app boot

After creating the cartridge, it is possible to check its status with the following command:

rhc cartridge status postgresql-9.2 --app boot

Step 3: Delete Template Application Source code

OpenShift creates a template project that can be freely removed:

git rm -rf .openshift README.md diy misc

Commit the changes:

git commit -am "Removed template application source code"

Step 4: Pull Source code from GitHub

git remote add upstream https://github.com/kolorobot/openshift-diy-spring-boot-sample.git
git pull -s recursive -X theirs upstream master

Step 5: Push changes

The basic template is ready to be pushed:

git push

The initial deployment (build and application startup) will take some time (up to several minutes). Subsequent deployments are a bit faster, although starting Spring Boot application may take even more than 2 minutes on small Gear:

Tomcat started on port(s): 8080/http
Started Application in 125.511 seconds

You can now browse to: http://boot-.rhcloud.com/manage/health and you should see:

{
	"status": "UP",
	"database": "PostgreSQL",
	"hello": 1
}

You can then browse to "/" to see the API root resource.

Step 6: Adding Jenkins

Using Jenkins has some advantages. One of them is that the build takes place in it's own Gear. To build with Jenkins, OpenShift needs a server and a Jenkins client cartridge attached to the application. Creating Jenkins application:

rhc app create ci jenkins

And attaching Jenkins client to the application:

rhc cartridge add jenkins-client --app boot

You can now browse to: http://ci-.rhcloud.com and login with the credentials provided. When you make next changes and push them, the build will be triggered by Jenkins:

remote: Executing Jenkins build.
remote:
remote: You can track your build at https://ci-<namespace>.rhcloud.com/job/boot-build
remote:
remote: Waiting for build to schedule.........

And when you observe the build result, the application starts a bit faster on Jenkins:

Started Application in 52.391 seconds

Under the hood

http://blog.codeleak.pl/2014/10/spring-boot-java-8-tomcat-8-on-openshift.html

openshift-diy-spring-boot-sample's People

Contributors

kolorobot avatar balicantayao avatar pavlikpolivka avatar lacivert avatar

Watchers

James Cloos avatar Sazzad Islam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.