0

I am trying to use Rush to handle a monorepo. I saw a recent, similar question at How to build for docker (rush monorepo)?, but it has no answers and is more about build issues than development issues.

Rush uses symlinks to avoid copying the same dependencies across different packages in same repo.

image of file system with symlinks to all node packages

I am using docker-compose for local dev as I would for any other project. The config is like this:

version: '3'
services:
  web:
    build: .
    image: 'my-image'
    command: "npm start"
    user: "node"
    working_dir: /home/node/app
    volumes:
      - ./:/home/node/app

When I do docker-compose up it can't find any of my dependencies. If I copy the folder to a random location, run npm install, and try the same it works because there are no symlinks.

I was debating doing a volume to the source location of ../../common/temp/node_modules/ but that that might be a bit crazy as it has every node modules for all the packages. The thing is that the files live outside of the folder structure of my server/docker package.

Is there some docker or rush optionality I am missing?

Dave Stein
  • 8,653
  • 13
  • 56
  • 104
  • The tool you describe doesn't really sound like it's compatible with Docker. Each image has its own isolated file system, and is intended to be self-contained; one image can't reference code or libraries that actually live in another image. – David Maze Jan 17 '23 at 00:54

2 Answers2

0

This works, but feels wrong. Hoping another user has a better answer.

volumes:
      - ./src/:/home/node/app/src
      - ../../common/temp/node_modules/:/home/node/app/node_modules
Dave Stein
  • 8,653
  • 13
  • 56
  • 104
0

I would guess that you have node_modules in your .dockerignore path, so it is not including the output of your install run from your host. When you do the volume, the empty folder then gets mapped over.

Bryan Latten
  • 332
  • 3
  • 10
  • There is no docker ignore file in these folders. – Dave Stein Jan 16 '23 at 20:46
  • Then good to check where those symlinks go. If they are linking outside the docker volume, then they will not resolve from within the container. This might be what you are seeing. If they are symlinking to a central cache directory, try temporarily configuring the cache to be within the project root. That would at least the symlinks resolvable, even if not a long-term solution. – Bryan Latten Jan 16 '23 at 21:47