Open zavvdev opened 1 year ago
Fairly easy to determine if it's a cargo-watch issue or not:
# build image
local> $ cd server; docker build -f Dockerfile.dev server
# start docker manually into a shell
local> $ docker run -it --rm -v $(pwd)/server/src:/usr/src/app/src -v $(pwd)/server/target:/usr/src/app/target server bash
# do cargo run twice in the container
container> $ cargo run
[Finished in X]
container> $ cargo run
[Finished in Y]
At a guess, though, I would say it's probably to do with the cargo cache in ~/.cargo
Hi! I'm playing with Rocket framework and created a monorepository with dockerized server service. I'm using cargo-watch for development mode and it works fine if I launching it locally. After saving source files it recompiles after ~0.68 seconds. But when I start server service inside docker container it takes too long. Near 2 minutes to restart.
This is my docker-compose.yml file:
docker-compose.dev.yml
And Dockerfile.dev:
As you can see, I've added src and target folder into the container volumes. I'm not sure if it's an issue with cargo-watch but it's really not obvious why it behaves like this. It looks like on each save it ignores cache and compiling from scratch. But container contains target folder. Does anyone know what's wrong there? Is this a cargo-watch issue?
You can find full repo here: https://github.com/zavvdev/rocket-svelte-rest/tree/main
Thanks!