Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 3.93 KB

README.md

File metadata and controls

64 lines (48 loc) · 3.93 KB

Highgarden

Why the name highgarden? Why not.

Highgarden is an example all-in-one webservice. It mounts up a REST-like service for maintaining a list of cars.

case class Car(id: Long, licenseNumber: String, color: String, name: Option[String])
Http Body Description Returns
GET localhost:8080/cars None Lists all cars in database List of cars
GET localhost:8080/cars/$id None Get car with id $id The requested car or 404
POST localhost:8080/cars Car Insert car with id The inserted car
PATCH localhost:8080/cars/$id Car Update car $id The updated car or 404
PUT localhost:8080/cars/$id Car Update car $id or insert if not existent The updated/inserted car
PUT localhost:8080/cars List[Car] Replace all cars with list The new list of cars
DELETE localhost:8080/cars/$id None Delete car None
DELETE localhost:8080/cars None Delete all cars None

About

Highgarden is built upon:

Library Description
Scala Scala programming language
Sbt Buildtool for scala
Sbt-assembly Create fatjars from sbt, used in docker images
Sbt-docker Create docker images from sbt
Scalafmt Codeformatter for Scala
Cats Functional library and effect monad
Doobie Functional JDBC for database access
Circe JSON parsing and encoding
Http4s HTTP services, server and client
embedded-postgres Embedded database for testing
Flyway Database migrations

Docker image available at Dockerhub

Running

Sbt

  1. sbt run

Access the server with curl localhost:8080/cars

Docker

Make sure to have docker installed

  1. create docker image with sbt docker
  2. docker run -d -i -p 8080:8080 <imageId>
  3. run sbt dockerPush to push image to dockerhub

Run docker ps to see the running image
Access the server with curl localhost:8080/cars

Kubernetes

  1. Install kubernetes comandline client, kubectl
  2. Set up client and connect to your cluster
  3. kubectl create -f deployment.yaml

Since deployment is based on latest-tag you can get the newest version by deleting the old pods.