I noticed whenever I build the docker image it builds, but fails to run npx and node commands in the dockerfile for the image. When the container for the image is up, I would not see a generate-typings.js file at all. But when I enter the container to run the script it works.
DockerFile
FROM node:14.17.6 as base
WORKDIR /usr/src/app
#copy package.json to docker container
COPY package.json ./
#For schema back end
COPY prisma/. /usr/src/app/prisma/.
COPY ts*.json ./
#For the database connection
COPY .env ./
#install package.json dependency
RUN npm i
#transfer code files
COPY ./src /usr/src/app/src/
#generate typings for graphql -- line not running in image
RUN npx - tsc --skipLibCheck /usr/src/app/src/gql/generate-typings.ts
#update the scheme
RUN node /usr/src/app/src/gql/generate-typings.js
#include nestjscli globally
RUN npm install -g @nestjs/cli
#generate
RUN npx prisma generate
docker-compose file
version: "3.9"
services:
api:
container_name: back_end_api
build:
context: .
dockerfile: Dockerfile
target: base
tty: true
expose:
- '4000'
ports:
- "4000:4000"
volumes:
- ./src:/usr/src/app/src #persist src folder to host machine
networks:
- emNetwork
command: npm run dev
networks:
emNetwork: