unlight / prisma-nestjs-graphql

Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module
MIT License
540 stars 79 forks source link

`yarn prisma generate` failed only in Docker #67

Open mikan3rd opened 3 years ago

mikan3rd commented 3 years ago

yarn prisma generate succeeds in the local environment, but fails with the following error when run in Docker.

Error: EIO: i/o error, open '/app/packages/backend/prisma/model/tenant-job/tenant-job-create-many-job.input.ts'

Strictly speaking, yarn prisma generate written in Dockerfile with docker-compose build succeeds, but it fails when I login to Docker after docker-compose up -d and run the same command.

It also succeeds when generator nestgraphql in schema.prisma is removed.

All log of command executions

/app # yarn @backend schema:generate
yarn run v1.22.5
$ yarn workspace backend schema:generate
$ yarn prisma generate
$ /app/node_modules/.bin/prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: 
✔ Generated Prisma Client (3.3.0) to ./../../node_modules/@prisma/client in 6.83s

Error: EIO: i/o error, open '/app/packages/backend/prisma/model/tenant-job/tenant-job-create-many-job.input.ts'

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed.
Exit code: 1
Command: /usr/local/bin/node
Arguments: /opt/yarn-v1.22.5/lib/cli.js schema:generate
Directory: /app/packages/backend
Output:

info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
generator nestgraphql {
  provider                   = "node ../../node_modules/prisma-nestjs-graphql"
  output                     = "./model"
  purgeOutput                = true
}

PS I am managing multiple packages with monorepo using yarn workspace.

unlight commented 3 years ago

Are you able to create files/directories by node.js in docker? Check in docker: node fs.writeFileSync('foo.txt', '') fs.mkdirSync('bar')

It is hard to say what is the problem (error is very general), maybe something related to permissions or disk.

mikan3rd commented 3 years ago

@unlight I ran the command you gave me and was able to create the files and directories without any problems.