Hello! I didn't found solution before so I will as...
# orm-help
s
Hello! I didn't found solution before so I will ask for help. I'm trying to dockerize my backend app. I'm doing everything right to generate and aplly migrations to database but when I do "npm run start" command to initialize my backend, it's return this error
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
I already made "prisma generate" command successfully in my dockerfile. How I can solve this? Thanks
r
@Simão Cruz 👋 Could you share you
Dockerfile
? Also are you generating
@prisma/client
in a different location?
s
Copy code
FROM node:14.16.0

# for caching optimisations
COPY package*.json /
COPY .babelrc /

RUN npm install --silent
RUN npm install -g prisma @prisma/client babel-cli

COPY ./prisma /prisma
COPY ./src /src

ENV PORT="8850"
ENV HOST="<http://localhost:8850>"
ENV DB="mybd"
ENV DBSCHEMA="public"
ENV DBUSER="prisma"
ENV DBPASSWORD="#####"
ENV DBSECRET="#####"
ENV DATABASE_URL="#####"

RUN prisma generate
RUN npm run build

ADD sayhello /sayhello
RUN chmod +x /sayhello

EXPOSE 8850

WORKDIR /

# wait for postgres init
ENV WAIT_VERSION 2.7.2
ADD <https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait> /wait
RUN chmod +x /wait

CMD ["/sayhello", "&&", "npm", "run", "start"]
And my /sayhello file just have this
echo prisma generate && prisma migrate dev -n init --preview-feature
Before run my dockerfile, I've started prisma and postgres images
r
@Simão Cruz I would suggest running the
npm install
after copying the
prisma
folder and also if you have a local installation of
@prisma/client
and
prisma
then this line is not needed:
Copy code
npm install -g prisma @prisma/client
This part can be removed.
Before run my dockerfile, I’ve started prisma and postgres images
I didn’t understand what you mean by prisma image?
s
Thanks Ryan. If I remove that line I cannot make a prisma generate (it says no prisma installed) In my docker-compose file, I call the prisma and postgres images from docker hub and pass the environment variables. In this point, its everthing ok