A sample Spring-based application
Java HTML CSS Shell Batchfile
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 10 commits ahead, 57 commits behind spring-projects:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.mvn/wrapper
deploy
src
.editorconfig
.gitignore
.springBeans
.travis.yml
Dockerfile
docker-compose.yml
mvnw
mvnw.cmd
pom.xml
readme.md
sonar-project.properties

readme.md

Spring PetClinic Sample Application Build Status

This is a fork of the Spring PetClinic project to show how to deploy an application using Wimpy. Every push/merge to this repository ends up in Travis deploying the application.

Configuration

The deploy folder contains the deployment configuration where we setup the basic Wimpy configuration

- hosts: localhost
  connection: local
  vars_files:
    - "{{ playbook_dir }}/{{ wimpy_deployment_environment }}.yml"
  vars:
    # Application name
    wimpy_application_name: "spring-petclinic"
    # Port where our application is listening for requests
    wimpy_application_port: 8080
    # Endpoint where actuator exposes the health check
    wimpy_aws_elb_healthcheck_ping_path: "/manage/health"
  roles:
    - role: wimpy.environment
    - role: wimpy.build
    - role: wimpy.deploy

Since we want to have different configuration values depending on the environment where we deploy, we load a different config file based on the wimpy_deployment_environment parameter. We may store secrets in these config files, so we have encrypted them using Ansible Vault. The password for Ansible Vault is passed in the .travis.yml file as an encrypted environment variable.

Continuous Deployment

The deploy folder also contains a deploy.sh script that gets executed in Travis for every merge/push to master. Although we don't recommend it, you can execute the script from your terminal to deploy without going through Travis.

Docker

Wimpy will deploy the application using Docker, so we need to provide a valid Dockerfile to build an image for the application. We make use of Docker multi stage build system to first generate the application JAR file using Maven, and then build the application Docker image using a minimal alpine based image with Java8.

FROM maven:3.5-jdk-8-alpine as BUILD

COPY . /usr/src/app
RUN mvn -f /usr/src/app/pom.xml clean package

FROM openjdk:8-jdk-alpine

COPY --from=BUILD /usr/src/app/target/*.jar /opt/app.jar
WORKDIR /opt
CMD ["java", "-jar", "app.jar"]

That Dockerfile is valid for any Maven application that runs on Java8. You can test the Docker image locally in your computer

$ docker build -t spring-petclinic .
$ docker run --rm -p 8080:8080 spring-petclinic