I was looking at the `ktor + docker` <documentatio...
# ktor
a
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
Thank you. I've created an issue KTOR-3294 that describes those two problems.
1
g
If you are targeting JVM, I would recommend to use Jib for building your docker image.