https://kotlinlang.org logo
#ktor
Title
# ktor
a

arthur_sav

10/19/2021, 4:10 PM
I was looking at the
ktor + docker
documentation which i found a bit incomplete. In particular, the suggested Dockerfile is this
Copy code
FROM openjdk:8-jdk
EXPOSE 8080:8080
RUN mkdir /app
COPY ./build/install/docker/ /app/
WORKDIR /app/bin
CMD ["./docker"]
However, ``./gradlew installDist`` has to be run manually before running docker which seems rather odd considering most use cases are deployment on the cloud. So here is an improved version that just runs without additional steps (builds both the source & docker image)
Copy code
FROM gradle:6-jdk8 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle installDist --no-daemon

FROM openjdk:8-jdk
EXPOSE 8080:8080
RUN mkdir /app
COPY --from=build /home/gradle/src/build/install/docker/ /app/
WORKDIR /app/bin
CMD ["./docker"]
Also, naming the project
docker
… could be confused with running docker itself.
a

Aleksei Tirman [JB]

10/20/2021, 9:54 AM
Thank you. I've created an issue KTOR-3294 that describes those two problems.
1
g

Guillermo Robles

10/20/2021, 7:54 PM
If you are targeting JVM, I would recommend to use Jib for building your docker image.
35 Views