I am running a Ruby on Rails app with Webpacker using Yarn and trying to run this on Docker via Docker Compose. When I run
docker compose build it looks like it runs successfully, but the node_modules folder is nowhere to be found and I can’t use any node packages. I tried adding
- /app/node_modules to the volumes as suggested in other posts but to no avail.
FROM ruby:3.0.0 RUN bundle config --global frozen 1 WORKDIR /app COPY Gemfile Gemfile.lock ./ RUN bundle install COPY . . RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - RUN apt-get install -y nodejs RUN npm install --global yarn RUN yarn install
version: "3.9" services: web: build: . ports: - "3000:3000" command: "rails server -b 0.0.0.0" volumes: - ./:/app - /app/node_modules db: image: "postgres:13" ports: - "5432:5432" volumes: - ./pgdata:/var/lib/postgresql/data environment: - POSTGRES_USER=user - POSTGRES_PASSWORD=password
Source: Docker Questions