Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again." When I try to dockerize my AdonisJS app with docker composer. #4834

Open
AlirezaEthDev opened this issue Dec 25, 2024 · 1 comment
Labels
Type: Invalid Doesn't really belong here. Maybe use discussion threads?

Comments

@AlirezaEthDev
Copy link

AlirezaEthDev commented Dec 25, 2024

Package version

5.8.0

Describe the bug

This is my docker file:

FROM node:20.12.2-alpine3.18 AS base

# Set the working directory inside the container
WORKDIR /app

# All dependencies stage
FROM base AS deps
COPY package.json package-lock.json ./
RUN npm ci --legacy-peer-deps

# Production-only dependencies stage
FROM base AS production-deps
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --legacy-peer-deps

# Build stage
FROM base AS build
COPY --from=deps /app/node_modules /app/node_modules
# Copy all application code, including prisma/schema.prisma
ADD . .  
# Generate Prisma Client
RUN npm run generate  
RUN node ace build --ignore-ts-errors && ls -l build  

# Production stage
FROM base AS production
ENV NODE_ENV=production
WORKDIR /app

# Copy only necessary files for production
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/build /app/build 
# Ensure .env file is copied if needed
COPY ./.env /app/build  

EXPOSE 3333

# Ensure server.js is in this path and run it
CMD ["node", "build/server.js"] 

And this is package.json of my app:

{
  "name": "pancake-back",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "node ace serve --watch",
    "build": "node ace build --production --ignore-ts-errors",
    "start": "node server.js",
    "generate": "prisma generate"
  },
  "devDependencies": {
    "@adonisjs/assembler": "^5.9.5",
    "@japa/preset-adonis": "^1.2.0",
    "@japa/runner": "^2.2.2",
    "@prisma/client": "^5.2.0",
    "@types/proxy-addr": "^2.0.0",
    "@types/source-map-support": "^0.5.6",
    "adonis-preset-ts": "^2.1.0",
    "pino-pretty": "^9.1.1",
    "prisma": "^5.2.0",
    "typescript": "~4.6",
    "youch": "^3.2.2",
    "youch-terminal": "^2.1.5"
  },
  "dependencies": {
    "@adonisjs/core": "^5.8.0",
    "@adonisjs/cors": "^2.2.1",
    "@adonisjs/repl": "^3.1.0",
    "@adonisjs/view": "^6.2.0",
    "@pancakeswap/sdk": "^3.1.4",
    "@pancakeswap/swap-sdk-core": "^0.0.1",
    "@pancakeswap/token-lists": "^0.0.4",
    "@vinejs/vine": "^1.6.0",
    "@wahyubucil/adonis-prisma": "^1.0.0",
    "axios": "^1.7.7",
    "big.js": "^6.2.1",
    "chai": "^5.1.1",
    "colors": "^1.4.0",
    "cors": "^2.8.5",
    "ethers": "^5.7.2",
    "express": "^4.21.1",
    "jsbi": "^4.3.0",
    "lodash": "^4.17.21",
    "mocha": "^10.7.3",
    "proxy-addr": "^2.0.7",
    "reflect-metadata": "^0.1.13",
    "simple-pancakeswap-sdk": "^1.1.1",
    "socket.io": "^4.7.2",
    "socket.io-client": "^4.8.1",
    "source-map-support": "^0.5.21",
    "web3": "^1.8.1",
    "winston": "^3.15.0"
  }
}

But when I try to build it with docker compose up --build, this error thrown:

app-1    | Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
app-1    | In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues
app-1    |     at new PrismaClient (/app/node_modules/.prisma/client/index.js:43:11)
app-1    |     at Object.callback (/app/node_modules/@wahyubucil/adonis-prisma/build/providers/PrismaProvider.js:39:28)
app-1    |     at Bindings.resolve (/app/node_modules/@adonisjs/fold/build/src/Ioc/Bindings.js:47:78)
app-1    |     at Ioc.resolveBinding (/app/node_modules/@adonisjs/fold/build/src/Ioc/index.js:266:37)
app-1    |     at Ioc.use (/app/node_modules/@adonisjs/fold/build/src/Ioc/index.js:312:21)
app-1    |     at Object.<anonymous> (/app/app/Controllers/Http/OrdersController.ts:3:1)
app-1    |     at Module._compile (node:internal/modules/cjs/loader:1369:14)
app-1    |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
app-1    |     at Module.load (node:internal/modules/cjs/loader:1206:32)
app-1    |     at Function.Module._load (node:internal/modules/cjs/loader:1022:12)

The error says prisma generate didn't run while RUN npm run generate on docker file does that job. So what is the problem?

Reproduction repo

No response

@RomainLanz
Copy link
Member

Hey @AlirezaEthDev! 👋🏻

This issue is related to Prisma, not AdonisJS. Please open a new issue or start a discussion on their repository.

@RomainLanz RomainLanz added the Type: Invalid Doesn't really belong here. Maybe use discussion threads? label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Invalid Doesn't really belong here. Maybe use discussion threads?
Projects
None yet
Development

No branches or pull requests

2 participants