I'm migrating our Ktor app to Docker Compose for l...
# ktor
m
I'm migrating our Ktor app to Docker Compose for local development, but I'm struggling to get watch mode working inside the container. It works if I run it directly on my machine, but inside the container I get:
No ktor.deployment.watch patterns match classpath entries, automatic reload is not active
Any ideas on what might be the issue? (It's running OpenJDK 1.8 in the container)
1
c
How do you run your app in a docker container? is it a fatjar or you are compiling it via gradle inside of the container?
m
Yeah, compiling it inside the container:
Copy code
CMD ["../gradlew", "run"]
c
How does your
watch
pattern look like?
And what is your main class? Is it
DevelopmentEngine
or your own class?
Are you sure that you use Java 8 (not 9) in your container?
m
Copy code
ktor {
  deployment {
    port = 8080
    watch = [gems]
  }
(All code is beneath
gems.*
namespace)
Main class is:
Copy code
fun main(args: Array<String>) {
    val environment = commandLineEnvironment(args)
    val server = embeddedServer(Netty, environment)
    server.start()
}
Copy code
$ docker exec -it backend java -version
openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-1~deb9u1-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
c
With debug loglevel it should be a full classloader urls list logged
something like
[DEBUG] Class Loader:
c
Ah I see..
adding
backend
to watches list should fix it
this is so disappointing problem
m
ah, OK, I see...apologies, I somehow got the impression the
watch
had to be a substring of the package, rather than the classloader URL, my bad 🤦
c
Yes, I don't know why it makes such impressioin
It's quite common
m
Well, thanks for helping me discover my stupidity 😉 Cheers!