Build Ktor Project and create Dockerfile

Опубликовано: 16 Июль 2026
на канале: Caelis
6,003
121

This episode is a preperation for the next hosting videos. We will cover at least hosting on Digital Ocean and a plain linux server, like Raspberry PI or Ubuntu/Debian VPS.

This video assumes that you already have a basic ktor webserver.
If you don't know how to setup one, see this video:
   • Web Server with Ktor #01 | Getting Started...  


Gradle FatJar-Task:
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': mainClassName
}
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

Dockerfile:
FROM openjdk:11-jdk-slim

WORKDIR /src
COPY . /src

RUN apt-get update
RUN apt-get install -y dos2unix
RUN dos2unix gradlew

RUN bash gradlew fatJar

WORKDIR /run
RUN cp /src/build/libs/*.jar /run/server.jar

EXPOSE 8081

CMD java -jar /run/server.jar



-► Resources:
♦ Source Code for this tutorial on GitHub: https://github.com/caelis-io/ktor-tod...
♦ Ktor Website: https://ktor.io/
♦ Kotlin Documentation: https://kotlinlang.org/

-► Links:
♦ YT Abo: http://bit.ly/CaelisAbo
♦ Website: https://caelis.me/
♦ Twitch: http://bit.ly/CaelisTwitch
♦ Twitter: http://bit.ly/CaelisTwitter
♦ Ask: http://bit.ly/CaelisAsk