Open SalihBorucu opened 1 year ago
IIUC you don't see changes made on host on bind mounted .:/var/www/my-app ? This sounds like a Docker Desktop issue we can't address from docker compose :'(
In the meantime you could give compose watch
a try and get file sync-ed into your development container: remove bind mount and add a x-develop section:
services:
app:
build:
context: ./docker/app
dockerfile: Dockerfile
image: my-app/app
ports:
- '${LARAVEL_WEBSOCKETS_PORT:-6001}:${LARAVEL_WEBSOCKETS_PORT:-6001}'
- "80:80"
- "8000:8000"
x-develop:
watch:
path: .
action: sync
then run docker compose alpha watch
@ndeloof Thank you for this suggestion, I am unable to use alpha commands "unknown docker command: "compose alpha"
Is there something extra I need to change to enable experimental commands?
this command is included in recent release only
volumes:
- .:/var/www/my-app
You are bind mounting files into your container @SalihBorucu - turn this off/comment out and instead add
COPY ./ /var/www/my-app
to your Dockerfile, and rebuild the container. Use with the latest Docker Desktop and docker compose with x-develop : watch : sync
as @ndeloof says. Docker compose version 2.17+
Note this is not the same as rebuilding the container when files are changed.
What File System option do you have selected in Docker Desktop General Settings? Use VirtioFS on MacOS for better performance.
These settings have been a total game changer for us. 90%+ performance increase on MacOS and large PHP monolith, 48K files, 900K loc, 48mb repo. I wrote it up and linked to the original blog post here.
Description
I actively work on this project for hours and everything works fine. Then at some point, the code changes I make on the files are ignored. Sometimes it is on all files and sometimes it is on a single file.
I was frustrated so reformatted the whole macbook just to resolve this, however, even after the reformat and reinstalling everything still facing the same issues.
The same project is also maintained by two other colleagues with exact same DockerFile and docker-compose.yaml and they have never faced this issue. One uses an M1 macbook other uses an identical with mine and we have almost no difference with the processes and applications we use.
The changes to the code are reflected if I
docker compose down
thendocker compose up
again.To debug, I used
docker compose exec app bash
into the container and usedless
to check if changes can be seen, the changes weren't there. However, when Iless
same file outside of the docker container, changes are there.So I experimented and used
nano
to change the file within the container and I could see the changes if I usedless
after but, when I run the code the changes weren't there.Somehow my old code is cached somewhere, yet I have no idea where.
Here is the app part of my docker-compose if that helps
However, as I said exact same docker-compose file works for everyone else.
I know it is a really vague issue but I can't find a way to re-create this since it doesn't even happen to my colleagues and because it happens to me occasionally.
If someone could even point me in the right direction to debug this it would be much appreciated.
Also, open to any wild theories and workarounds since I am completely out of ideas.
Thank you
My current version of Docker Desktop is: 4.17.0 (99724) Using Macbook 2019 - Ventura
Steps To Reproduce
No response
Compose Version
Docker Environment
Anything else?
No response