Skip to content

Simple Spring Boot app with a REST API against a database

Notifications You must be signed in to change notification settings

ciber-openshift-workshop/yaapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaapp

Yet another application. This is a simple example of spring-data-jdbc and spring-data-rest running in a Spring Boot app against a PostgreSQL database. Demonstrates that minimalistic CRUD is possible with no application-specific code.

Status

Java CI with Maven

Building

Maven packaging

$ mvn package

Build and publish Docker image with Jib

$ mvn jib:build

Running

To run locally you can start a PostgreSQL server and adjust settings accordingly in application.properties (or env. variables or system properties).

Run everything as Docker containers

This assumes you have built and pushed the image with Jib beforehand.

  1. Create a shared Dockernetwork:
    $ docker network create --driver bridge mynet
    
  2. Start a PostgreSQL container:
    $ docker run --net=mynet -p 5432:5432 --rm  --name yaapp-db -e POSTGRES_PASSWORD=<MY_PG_PASSWORD> -d postgres:0.0.1-SNAPSHOT
    
    NB: The PostgreSQL password must match what you provide to the app later on.
  3. Start the app:
    $ docker run --net=mynet -p 8080:8080 -e SPRING_DATASOURCE_URL=jdbc:postgresql://yaapp-db:5432/postgres -d yaapp:0.0.1-SNAPSHOT