Codename: Desert Snake

Testing the Spring Boot framework. The idea is to create a REST microservice, package it to docker and serve it from a Kubernetes cluser in the cloud.

Useful links

Prerequesites

  • Java 8
  • Postgres server
  • Docker
  • Maven 3.5.2

Major Dependencies

  • Spring Boot
  • Flyway
  • Postgres
  • Docker

Setup instructions

Development

No Docker
  1. Create TWO postgres databases, one for running the application, and one for automated tests. You can use the SQL below.
  2. Create a user in Postgres with full rights on the databases (see below).
  3. In src/main/java/resources:
    1. Copy application-local.properties-example to `application-local.properties'
    2. Enter the correct database credentials in the local config.
  4. Repeat for src/test/java/resources.
  5. Run mvn clean install. The project should compile, and all tests should pass.
Docker
  1. <...>

Deploy a self-contained jar

  1. From the project root directory: mvn clean package. This creates an self contained web server.
  2. Create a local config in a secure directory, outside of the webroot.
    1. Example: ~/.desertsnake/application.config
    2. chmod -R 700 ~/.desertsnake
  3. Run the application: java -jar -Dspring.config.location=~/.desertsnake/application.config.

Database creation example

-- Create database
CREATE DATABASE desertsnake;

-- Create user
CREATE ROLE developer WITH LOGIN PASSWORD '<password>';
GRANT ALL PRIVILEGES ON DATABASE desertsnake TO developer;

Useful stuff

mvn -Dflyway.url=jdbc:postgresql://localhost:5433/desertsnake_develop -Dflyway.user=developer -Dflyway.password=testpassword