I am a docker beginner and trying to dockerize simple projects as part of my learning journey..
I am trying to dockerize a NestJS project, but the docker-compose
up command fails.
My Dockerfile and docker-compose.* files look as below. I have tried various changes to Dockerfile and docker-compose files but with no luck.. Can some spot the issue or something that I am missing.
Dockerfile
FROM node:12.10
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm build
docker-compose.yml
version: '3'
services:
app:
build: .
ports:
- '8081:8081'
docker-compose.dev.yml
version: '3'
services:
app:
command: npm start
volumes:
- .:/usr/src/app
environment:
- NODE_ENV=development
And, here's the command I run...
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
The command fails with below error
Attaching to nestjs-api-server_app_1
app_1 |
app_1 | > BookAPI@0.0.1 start /usr/src/app
app_1 | > npm run copy-resources && nodemon --watch src -e ts,tsx --exec ts-node src/main.ts
app_1 |
app_1 |
app_1 | > BookAPI@0.0.1 copy-resources /usr/src/app
app_1 | > ts-node scripts/copy-resources.ts
app_1 |
app_1 | sh: 1: ts-node: not found
app_1 | npm ERR! code ELIFECYCLE
app_1 | npm ERR! syscall spawn
app_1 | npm ERR! file sh
app_1 | npm ERR! errno ENOENT
app_1 | npm ERR! BookAPI@0.0.1 copy-resources: `ts-node scripts/copy-resources.ts`
app_1 | npm ERR! spawn ENOENT
app_1 | npm ERR!
app_1 | npm ERR! Failed at the BookAPI@0.0.1 copy-resources script.
app_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
app_1 | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
app_1 |
app_1 | npm ERR! A complete log of this run can be found in:
app_1 | npm ERR! /root/.npm/_logs/2020-02-27T20_07_39_822Z-debug.log
app_1 | npm ERR! code ELIFECYCLE
app_1 | npm ERR! errno 1
app_1 | npm ERR! BookAPI@0.0.1 start: `npm run copy-resources && nodemon --watch src -e ts,tsx --exec ts-node src/main.ts`
app_1 | npm ERR! Exit status 1
app_1 | npm ERR!
app_1 | npm ERR! Failed at the BookAPI@0.0.1 start script.
app_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
app_1 | npm WARN Local package.json exists, but node_modules missing, did you mean to install?
app_1 |
app_1 | npm ERR! A complete log of this run can be found in:
app_1 | npm ERR! /root/.npm/_logs/2020-02-27T20_07_39_847Z-debug.log
nestjs-api-server_app_1 exited with code 1