skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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
    

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search