docker compose not creating node_modules

Viewed 50

I have a simple folder structure like this

/myProyect
|_src/
|_index.ts
|_node_modules/
|_package.json
|_package-lock.json
|_docker-compose.yml
|_Dockerfile

inside my docker-compose.yml the structure is also simple

version: "3.2"
services:
  app:
    restart: always
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ./:/app
    command: "yarn dev"

volumes:
  data-volume:

And my Dockerfile looks like this

FROM node:14.16-buster-slim

WORKDIR /app/
COPY . /app/
RUN yarn install

EXPOSE 3000

The command I'm running to build (and then start) the docker compose is just docker compose build

What I want to achieve is that once the docker compose build command is run the node_modules folder should be created in my local and the container

I know there is a way and I'm missing something with the volumes.

Can anyone please help me?

0 Answers
Related