prisma/prisma

Run Prisma on docker use elysia/Bun js

PeaceAntoHim opened this issue · 1 comments

Bug description

I got err when run my app that use prisma as orm, for my case I was success generate prisma but somehow at runtime doesn't success initial prisma and got this err message:

Init prisma connection
elysia-app-1  | Error Connecting to Prisma:  38 | var clientVersion = version;
elysia-app-1  | 39 |
elysia-app-1  | 40 | // src/scripts/default-index.ts
elysia-app-1  | 41 | var PrismaClient = class {
elysia-app-1  | 42 |   constructor() {
elysia-app-1  | 43 |     throw new Error(
elysia-app-1  |                ^
elysia-app-1  | error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
elysia-app-1  | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report
elysia-app-1  |       at new PrismaClient (/app/node_modules/.prisma/client/default.js:43:11)
elysia-app-1  |       at prismaConnection (/app/src/dependency-injection/dependency-injection.init.ts:13:34)
elysia-app-1  |       at new Application (/app/src/dependency-injection/dependency-injection.ts:30:57)
elysia-app-1  |       at /app/src/dependency-injection/dependency-injection.ts:66:20
elysia-app-1  |
elysia-app-1  | 38 | var clientVersion = version;
elysia-app-1  | 39 |
elysia-app-1  | 40 | // src/scripts/default-index.ts
elysia-app-1  | 41 | var PrismaClient = class {
elysia-app-1  | 42 |   constructor() {
elysia-app-1  | 43 |     throw new Error(
elysia-app-1  |                ^
elysia-app-1  | error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
elysia-app-1  | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report
elysia-app-1  |       at new PrismaClient (/app/node_modules/.prisma/client/default.js:43:11)
elysia-app-1  |       at prismaConnection (/app/src/dependency-injection/dependency-injection.init.ts:13:34)
elysia-app-1  |       at new Application (/app/src/dependency-injection/dependency-injection.ts:30:57)
elysia-app-1  |       at /app/src/dependency-injection/dependency-injection.ts:66:20

But before that I was success build the image:

 => [elysia-app internal] load build definition from Dockerfile                                                                                                                                                                  0.0s
 => => transferring dockerfile: 594B                                                                                                                                                                                             0.0s 
 => [elysia-app internal] load metadata for docker.io/oven/bun:latest                                                                                                                                                           10.1s 
 => [elysia-app auth] oven/bun:pull token for registry-1.docker.io                                                                                                                                                               0.0s
 => [elysia-app internal] load .dockerignore                                                                                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                                                                                                  0.0s 
 => [elysia-app 1/9] FROM docker.io/oven/bun:latest@sha256:6ffc613400a5b69c0b0f0e1d5d954b1656b928f4b254a340dc1fd03377dd7151                                                                                                      0.0s 
 => [elysia-app internal] load build context                                                                                                                                                                                     0.1s 
 => => transferring context: 8.16kB                                                                                                                                                                                              0.0s 
 => CACHED [elysia-app 2/9] WORKDIR /app                                                                                                                                                                                         0.0s
 => CACHED [elysia-app 3/9] COPY package.json .                                                                                                                                                                                  0.0s 
 => CACHED [elysia-app 4/9] COPY bun.lockb .                                                                                                                                                                                     0.0s 
 => CACHED [elysia-app 5/9] COPY tsconfig.json .                                                                                                                                                                                 0.0s 
 => [elysia-app 6/9] COPY prisma prisma                                                                                                                                                                                          0.1s 
 => [elysia-app 7/9] COPY src src                                                                                                                                                                                                0.1s
 => [elysia-app 8/9] RUN bun install --frozen-lockfile --production                                                                                                                                                              8.3s
 => [elysia-app 9/9] RUN bunx prisma generate                                                                                                                                                                                    1.8s
 => [elysia-app] exporting to image                                                                                                                                                                                              0.9s
 => => exporting layers                                                                                                                                                                                                          0.8s
 => => writing image sha256:8af836ddbe513ee17b2b4c978cc033a451acec6b01f33e72d9c5199b398532ed                                                                                                                                     0.0s
 => => naming to docker.io/library/be-assignment-elysia-app 

this my dockerfile

FROM oven/bun:latest
# Set working directory
WORKDIR /app

# Copy package.json and bun.lockb for dependency installation
COPY package.json .
COPY bun.lockb .

# Copy other necessary files
COPY tsconfig.json .
COPY prisma prisma
COPY src src

# Install dependencies using bun
RUN bun install --frozen-lockfile --production

# Set NODE_ENV to production
ENV NODE_ENV production

# Generate Prisma client
RUN bunx prisma generate

# Expose port
EXPOSE 3000

# Define the command to run your application
CMD ["bun", "src/index.ts"]

How to reproduce

Expected behavior

No response

Prisma information

// Add your schema.prisma
// Add your code using Prisma Client

Environment & setup

  • OS:
  • Database:
  • Node.js version:

Prisma Version


Hi! I'm converting this issue to a support question, so that my colleagues will be able to help you out :)