Coder Social home page Coder Social logo

spring-petclinic's Introduction

Spring Pet Clinic and the Developer Sandbox for Red Hat OpenShift

This repo contains a container-ready implementation of the iconic Spring Petclinic application. Specifically, this code is useful with the OpenShift Source-to-Image (s2i) technology and is part of the introductory material for Developer Sandbox for Red Hat OpenShift.

OpenShift Implementation

Get your free OpenShift cluster to run this demo. You can get free access to Developer Sandbox for Red Hat OpenShift at: https://developers.redhat.com/developer-sandbox

Dev Console

Make sure you are in the Developer perspective:

Dev Perspective

The first step is create a database to hold our data. We'll use a MySQL Image to do this.

Click the +Add button and choose the Container images option:

Container images option

Enter the MySQL image we need, docker.io/mysql:5.7.41

MySQL image entry

Scroll to the bottom of the page and select the option to access advanced options for a Deployment:

deployment options

Using the Environment variables section, specify the database and authentication values by adding the following four environment variables.

Environment variables

When they are entered, click the "Resource type" link. Select "Deployment" as the Resource type:

MySQL Ephemeral

Click the Create button.

After a few minutes, and behind the scenes, a MySQL database container will be started. At this point, you have a database engine to be used by the application. Time to move on and create the application.

Deploy Pet Clinic App

Click the +Add button and choose Import from Git type:

Fill the git repo with the following value https://github.com/redhat-developer-demos/spring-petclinic. This is where things get interesting.

When you enter the URL for a git repo, OpenShift will look at the files in the repo and attempt to discern the best way to build the application. There are three possible results:

  1. Build using the file "devfile.yaml" found in the source code
  2. Build using the file "dockerfile" found in the source code
  3. If neither of the above two files are found, build using a builder image and the built-in source-to-image (s2i) technology. This is the focus of this article.

If, the case of this example (i.e. Spring Petclinic), OpenShift does not choose the builder image option, you will need to direct it to do so. Here's how to do that:

First, click on the "Edit Import Strategy" link:

Edit Import Strategy

Next, choose the Builder Image option and make sure the Java builder is selected:

Choose builder image

Scroll down to the Advanced options section and select the option to change the Resource type:

Select Resource type

Choose the Deployment option:

Deployment resource type

Near the bottom of the page, click the Build Configuration link:

Build Configuration

Add the following environment variables, as displayed in the following screen capture:

SPRING_PROFILES_ACTIVE=mysql
MYSQL_URL=jdbc:mysql://mysql:3306/petclinic

DC Env Vars

Finally click the Create button and wait until the Build is done and the Pod is up and running (dark blue around the deployment bubble). In testing this using the Developer Sandbox for Red Hat OpenShift, this step took approximately six minutes. Please note: You may see error messages in the Sandbox. They are temporary while the application builds.

Then push the Open URL button to view the Pet Clinic app:

Pet Clinic Deployment

Pet Clinic UI

And if you visit the MySQL deployment's Terminal then you connect to the database to see the schema and data

mysql -u root -h mysql -p

petclinic

use petclinic;
show tables;

MySQL Terminal

select * from owners;

MySQL Terminal ### End ###

spring-petclinic's People

Contributors

blues-man avatar burrsutter avatar donschenck avatar doyoungim999 avatar japerinan avatar joellord avatar jwennerberg avatar mahimagupta-del avatar sujaysail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spring-petclinic's Issues

Getting errors parsing the devfile.yaml when deploying spring-petclinic app on openshift trial version

I am getting errors when pointing the github spring-petclinic for deployment. I have attached the screenshot showing the error

Import is not possible.
Failed to parse devfile: invalid devfile schema. errors : - (root): schemaVersion is required - (root): Additional property apiVersion is not allowed - commands.0: Must validate one and only one schema (oneOf) - commands.0: exec is required - commands.0: id is required - commands.0: Additional property actions is not allowed - commands.0: Additional property name is not allowed - commands.1: Must validate one and only one schema (oneOf) - commands.1: exec is required - commands.1: id is required - commands.1: Additional property actions is not allowed - commands.1: Additional property name is not allowed - commands.2: Must validate one and only one schema (oneOf) - commands.2: exec is required - commands.2: id is required - commands.2: Additional property actions is not allowed - commands.2: Additional property name is not allowed - commands.3: Must validate one and only one schema (oneOf) - commands.3: exec is required - commands.3: id is required - commands.3: Additional property actions is not allowed - commands.3: Additional property name is not allowed - commands.4: Must validate one and only one schema (oneOf) - comm

Screen Shot 2022-03-09 at 12 50 34 PM

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.