Hey I was wondering how to setup docker build with...
# ktor
t
Hey I was wondering how to setup docker build with github actions just to see if my code actually compiles. It currently errors out with this
When using COPY with more than one source file, the destination must be a directory and end with a /
however if I add a
/
to the end of the copy statement it stops building locally. Here's the Dockerfile
Copy code
FROM gradle as build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle buildFatJar --no-daemon

FROM openjdk:17
EXPOSE 8080:8080

RUN mkdir /app
COPY --from=build /home/gradle/src/build/libs/*.jar /app/ktor-app.jar
ENTRYPOINT ["java", "-jar", "/app/ktor-app.jar"]
t
Not sure if this wouldn't work for you, but there is https://ktor.io/docs/docker.html This uses a plugin which delegates to
jib
https://github.com/GoogleContainerTools/jib to build your container instead of using a Dockerfile. This adds gradle tasks to build and run the container
c
Alternatively, this is a Dockerfile that works: https://gitlab.com/opensavvy/formulaide/-/blob/main/.gitlab/backend.dockerfile Just run
./gradlew assembleDist
before building it
t
Does it work with GitHub actions? That’s the main problem I’m experiencing at the moment
c
It's just a Dockerfile, it runs in whatever runs a Dockerfile
t
With the error message I stated above that only occurs with GitHub actions however locally it’s fine, it’s weird
c
Old version of Docker in one of the two envs?
t
Perhaps, let me quickly check my local docker version
I'm running 20.10.17
t
using the ktor jib plugin builds without issue on github actions for me
also do you know which copy isn't working?
COPY --from=build /home/gradle/src/build/libs/*.jar /app/ktor-app.jar
This seems like it could be the problem due to that wildcard
t
Yeah that's the copy that isn't working, do you by chance have a solution to that or just recommend me to use jib?
I don't have much experience with Docker/CD stuff so I'd prefer to stay away from things such as jib since I don't really understand it at the moment 😅
t
using the ktor docker plugin would most likely be easiest tbh unless you really want to learn dockerfiles
This is a dockerfile that outputs similar to jib
this could probably guide you to fixing your problem though
t
Interesting, I'll try it out thank you so much.