Giter Site home page Giter Site logo

devopsglobalsolutions / petclinic-spinnaker-jenkins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibuchh/petclinic-spinnaker-jenkins

0.0 1.0 1.0 519 KB

Spring Petclinic Application - CI/CD Pipeline using Spinnaker and Jenkins

Dockerfile 0.14% Java 70.57% CSS 7.23% TSQL 1.63% HTML 13.16% HCL 5.79% Shell 0.99% Smarty 0.50%

petclinic-spinnaker-jenkins's Introduction

Spring PetClinic Sample Application Build Status

Understanding the Spring Petclinic application with a few diagrams

Running petclinic locally

Petclinic is a Spring Boot application built using Maven. You can build a jar file and run it from the command line:

git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
./mvnw package
java -jar target/*.jar

You can then access petclinic here: http://localhost:8080/

petclinic-screenshot

Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):

./mvnw spring-boot:run

In case you find a bug/suggested improvement for Spring Petclinic

Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues

Database configuration

In its default configuration, Petclinic uses an in-memory database (HSQLDB) which gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed. Note that whenever the database type is changed, the app needs to be run with a different profile: spring.profiles.active=mysql for MySql.

You could start MySql locally with whatever installer works for your OS, or with docker:

docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
docker exec -it mysql bash
mysql -uroot -p

Create the DB schema and the database tables by running the scirpts inside the initDB.sql and populateDB.sql files

Create a jar file under target directory:

mvn package -DskipTests=true

Run the application using mysql profile

java -Dspring.profiles.active=mysql -jar target\spring-petclinic-2.0.0.jar

Run the application using hsqldb profile

java -Dspring.profiles.active=hsqldb -jar target\spring-petclinic-2.0.0.jar

Running Petclinic using Docker

Inside the Dockerfile, create the last line as:

ENTRYPOINT [ "sh", "-c", "java -Dspring.profiles.active=${ENV} -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]

Create a docker image and push it to the Docker Hub

And while running the docker:

docker run --env ENV=mysql -d -p 8080:8080 <image id> 

This way, environment variable gets local as value and passes to Dockerfile when we bring up a container.

You can also pass on the Spring Profile as an environment variable at the run time as:

$ docker run -e "SPRING_PROFILES_ACTIVE=prod" -p 8080:8080 -t ibuchh/spring-petclinic

Petclinic environment variables

https://stackoverflow.com/questions/51655725/how-can-i-set-spring-boot-properties-from-docker-run-command?noredirect=1&lq=1

http://www.littlebigextra.com/use-spring-profiles-docker-containers/

https://www.mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/

https://dzone.com/articles/spring-boot-profiles-1

Working with Petclinic in your IDE

Prerequisites

The following items should be installed in your system:

Steps:

    1. On the command line ``` git clone https://github.com/spring-projects/spring-petclinic.git ```
    1. Inside Eclipse or STS
    File -> Import -> Maven -> Existing Maven project
    

    Then either build on the command line ./mvnw generate-resources or using the Eclipse launcher (right click on project and Run As -> Maven install) to generate the css. Run the application main method by right clicking on it and choosing Run As -> Java Application.

    1. Inside IntelliJ IDEA

    In the main menu, choose File -> Open and select the Petclinic pom.xml. Click on the Open button.

    CSS files are generated from the Maven build. You can either build them on the command line ./mvnw generate-resources or right click on the spring-petclinic project then Maven -> Generates sources and Update Folders.

    A run configuration named PetClinicApplication should have been created for you if you're using a recent Ultimate version. Otherwise, run the application by right clicking on the PetClinicApplication main class and choosing Run 'PetClinicApplication'.

    1. Navigate to Petclinic

    Visit http://localhost:8080 in your browser.

petclinic-spinnaker-jenkins's People

Contributors

ibuchh avatar scottdspangler avatar

Watchers

James Cloos avatar

Forkers

scottdspangler

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.