docker on Development enviroment with compiled language (typescript)

I have 10 microservices that written on typescript, I want to run
docker-compose up --build that will :

  • build each container

  • compile the typescript

  • run each microservice with pm2

I want to be able to edit the code on my host with “vscode”, and see the changes on the container

I tried to copy the files on the docker file , build them.
but when I mount the volume it overrides my code and I cant run it with pm2

docker compose

version: '3'
services:
  web_service_1:
    container_name: m1_container
    build:
      context: ./
      dockerfile: Dockerfile
    ports:
      - 3014:3014
    volumes: 
      - ./:/source/m1

docker file

FROM ubuntu:18.04

RUN mkdir -p /source/m1 

RUN apt-get update && apt-get install -y sudo &&  apt-get install -y curl

#install node js
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
RUN apt-get install -y nodejs

#typescript
RUN npm install -g [email protected]
#pm2 3.2.4
RUN  npm install [email protected] -g
#text editor
RUN sudo apt-get install nano
# RUN sudo apt-get install vim

#copy project files
COPY ./m1 /source/m1

#create dist folder
RUN mkdir dist

#build the typescript
RUN cd /source/m1 && tsc

#run with pm2
CMD ["pm2-runtime", "/source/m1/ecosystem.config.js"]

there is any solution that I will avoid ssh to each container build and run the code?

Source: StackOverflow