I use docker-compose with multistage building for create my services. I want build node (install nodejs, install node modules, build assets) and just share resulting artifacts to app container. So in fact i need share node_modules and dist folders from node container to app container. In my case i use something like this:
version: "2.3" networks: frontend: driver: "bridge" services: app: build: context: ./docker/app volumes: - ./:/app working_dir: /app networks: - frontend ports: - "8000:8000" ... node: build: dockerfile: ./docker/node/Dockerfile context: . target: dev user: node working_dir: /home/node/app volumes: - ./:/home/node/app
(installation nodejs and modules inside my Dockerfile)
It turns out that when the containers is started, the compiled files are not shared with the host machine. But if i rum docker-compose run --rm -u node node touch 123.txt, new file will be succesfully shared to host machine.
The question: how to share build time artisacts to hosts machine with docker-compose?