aedenj / ktor-starter

0 stars 0 forks source link

Ktor Starter (In Progress)

License Build ktlint OpenSSF Scorecard

Overview

This starter is a set of utilities built on top of Ktor to quickly bootstrap a microservice. This starter sets up the following features:

Service

Infrastructure

Pre-Requisites

  1. Docker
  2. Terraform - for infrastructure as code.
  3. Terragrunt - for managing multiple Terraform environments.
  4. Gradle - via your preferred development workflow.

I typically manage installations using asdf, but to each their own. If you do use, asdf, there is a .tool-versions file in the root of the project that you can use for installation.

Up & Running

Let's first clone the repo and fire up our system,

git clone git@github.com:aedenj/ktor-starter.git ~/projects/ktor-starter
cd ~/projects/ktor-starter;docker compose up

This will start the app on port 8080. Navigate to http://localhost:8080 to see the app running.

Live Reload

When running the service via docker compose Ktor's auto-reload functionality is enabled. This means that if you open a separate terminal and run the command ./gradlew -t build -x test -i when you make changes to the code, the service will automatically reload.

Troubleshooting

Got output:

credentials not found in native keychain

The credential helper (docker-credential-desktop) has nothing for server URL: registry-1.docker.io

Make sure the task is actually failing. Jib tries serveral hosts and you may have credentials setup for one of them. If the task is failing, you can fix this by running the following commands,

  1. Run docker login registry-1.docker.io and enter your Docker Hub credentials.

  2. Re-run the JIB task.