Skip to content

This project is for testing development with docker, kotlin, gradle, ktor and postgreSQL

License

Notifications You must be signed in to change notification settings

MikAoJk/docker-kotlin-gradle-ktor-postgres

Repository files navigation

build main branch GitHub issues GitHub pull requests GitHub

docker-kotlin-gradle-ktor-postgres

This project is for testing development with docker, kotlin, gradle, ktor and postgreSQL

Technologies used

  • JDK 21
  • Kotlin
  • Gradle
  • Docker
  • Ktor
  • Postgres
  • Editorconfig

Getting started

Prerequisites

Make sure you have the Java JDK 21 installed You can check which version you have installed using this command:

java -version

Make sure you have the Docker installed You can check which version you have installed using this command:

docker --version

Make sure you have the Docker-compose installed You can check which version you have installed using this command:

docker-compose --version

Running the application locally

Building the application

To build locally and run the integration tests you can simply run

./gradlew shadowJar

or on windows gradlew.bat shadowJar

Creating a docker image

Creating a docker image should be as simple as

docker build -t docker-kotlin-gradle-ktor-postgres .

Running a docker image

docker run -d --rm -it -p 8080:8080 -e "DATABASE_HOST_URL=db" docker-kotlin-gradle-ktor-postgres

Integrasion testing the application

Running the postgresSql db from docker compose

docker-compose -p docker-kotlin-gradle-ktor-postgres-compose up -d

Tear down the postgresSql db from docker compose

docker-compose -p docker-kotlin-gradle-ktor-postgres-compose down

Run the main class in your favoritt IDE(Intellij)

Go to src/main/kotlin/Application.kt and run the main method

Testing the endpoint

Api doc

http://localhost:8080/swagger

For testing the endpoint ValidateDataApi You need a tool to send a request and to inspect the repsonse A tool you can use is Postman: https://www.postman.com/downloads/ The endpoint is currently available at http://0.0.0.0/v1/validate when running the application locally Set the body in the request, example: {"data":"DATA"} and profit

Example of a request:

`curl --location --request POST 'http://0.0.0.0:8080/v1/validate' \
--header 'Content-Type: application/json' \
--data-raw '{"data":"DATA"}'`

Example of a response: {"result":"OK"}

Upgrading the gradle wrapper

Find the newest version of gradle here: https://gradle.org/releases/ Then run this command: (Remeber to repealce $gradleVersjon with newest version)

./gradlew wrapper --gradle-version $gradleVersjon

Contribute

Want to add a feature? see CONTRIBUTING

Contact

This project is maintained by CODEOWNERS

Questions please create an issue

About

This project is for testing development with docker, kotlin, gradle, ktor and postgreSQL

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published