I am using Typescript here and using
node:latest in Docker, and I am using
docker-compose as well,
I always failed to run it with docker-compose, when I run
docker run ( manual ) it was work well,
here is my
FROM node:latest RUN mkdir -p /home/myapp WORKDIR /home/myapp RUN npm i -g prisma2 ENV PATH /home/myapp/node_modules/.bin:$PATH COPY package.json /home/myapp/ RUN npm install COPY . /home/myapp RUN prisma2 lift save --name 'init' RUN prisma2 lift up EXPOSE 8100 RUN npm run build RUN pwd RUN ls RUN ls dist CMD node dist/server.js
version: "3" services: app: environment: DB_URI: postgres://myuser:[email protected]:5555/prod NODE_ENV: production build: context: . dockerfile: Dockerfile depends_on: - postgres volumes: - ./home/edupro/:/home/myapp/ - ./node_modules:/home/myapp/node_modules ports: - "8100:8100" postgres: container_name: postgres image: postgres:10-alpine ports: - "5555:5555" environment: POSTGRES_USER: myuser POSTGRES_PASSWORD: password POSTGRES_DB: prod
when it finishes doing CMD
node /dist/server.js ( which folder I build because I am using TYpescript )
it gets an error like this :
Cannot find module '/home/edupro/dist/server.js'
I have to try to change
docker-compose.yml as well like this:
but still the same. do I miss something ? or did wrong mount?
how is the correct way to resolve that?