odfsoft / spring-boot-guess-game

Spring Boot Guess game using Webflux and github actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to "Spring-boog-guess-game" with GitHub Actions

the main goal of this repo is to create a guessing game app using spring-boot-webflux, which will store the game information in a postgres database. the application will run in an AWS EKS cluster, the deployment pipeline will use github actions for CI/CD.

Prerequisities

  • Java 8 / maven etc
  • Docker
  • Kubectl
  • helm

Tech Stack:

Steps

  1. create a sample application using spring boot initilizr: for this app I used version 2.2 RC1 with kotlin and maven.
  2. lets add some features to the empty spring boot repo, the api should:
  • Create a game, which generate a random number and store's it in session. Request: curl -X POST http://localhost:8080/api/games response:
{
    "id": "7e37b1ec-e40c-425a-9757-abf8a57ffb91",
    "guess": 461
}
  • Get a game with the id returned in the previous request. Request: curl -X GET http://localhost:8080/api/game/7e37b1ec-e40c-425a-9757-abf8a57ffb91 Response:
{
    "id": "7e37b1ec-e40c-425a-9757-abf8a57ffb91",
    "guess": 461
}
  • receive guesses, the api will response with a 200 and message text either saying too low, too high, congratulations you guessed. Request: curl -X POST http://localhost:8080/api/game/7e37b1ec-e40c-425a-9757-abf8a57ffb91/guess -H 'Content-Type: application/json' -d '{"guessNumber": 10}' Response:
{
    "message": "your guess is too low"
}

TODO: create a step by step guide to the previous setup. 2) Dockerize the application using Jib the project will use Jib for dockerization, hence no Dockerfile, Use ./mvnw compile jib:dockerBuild to build to a local Docker daemon, this command should create a docker image with the name guess-game. lets run the docker container locally: docker container run --name guess-game -p 8080:8080 -d guess-game if you try the calls on the previous step they should still work: Request: curl -X POST http://localhost:8080/api/games response:

{
    "id": "7e37b1ec-e40c-425a-9757-abf8a57ffb91",
    "guess": 461
}
  1. lets make github actions run the test cases as part of the pipeline the idea is to run all the test cases when we push to a branch, and to build and deploy when we merge into master
  1. lets create a EKS cluster to run our docker container in a kubernetes managed cluster
  2. lets automate the deploy on merge to master in github actions.
  3. lets run some perfromance testing on it
  4. lets add it to our github actions pipeline.

About

Spring Boot Guess game using Webflux and github actions


Languages

Language:Kotlin 100.0%