Closed jdaibello closed 5 months ago
@jdaibello Thanks for asking, I'll test it when I have time, my guess is that the odroe/prisma-dart
image is not properly providing the binary dependencies needed by MongoDB.
You should be able to tell what's missing from your Docker running logs, but I'd still follow the minimal example you provided to test it.
However, I can't guarantee a time, if you read my tweets you should know that our team is suffering from insufficient funds. Currently busy getting the team back on track, so I'll look into this as soon as I have as much free time as possible.
@jdaibello Also, here's what I can offer to help troubleshoot this issue:
DATABASE_URL=postgres://seven@localhost:5432/prisma-dart?schema=public <Prisma binary engine path> -m -g -r --datamodel -path example/prisma/schema.prisma -p 8080
code, replace URL with your desired database address.builder
image.@medz I did your suggestion above, but the result in Docker logs is the same
My package.json
{
"scripts": {
"prisma:engine": "DATABASE_URL=mongodb+srv://username:password@mongodbcluster.gnuipvt.mongodb.net/soccer-stories node_modules/prisma/query-engine-darwin -m -g -r --datamodel-path prisma/schema.prisma -p 8080"
},
"prisma": {
"schema": "prisma/schema.prisma"
},
"dependencies": {
"prisma": "^4.13.0"
}
}
My node_modules/prisma folder shows the query-engine-darwin-arm64
file when I run the prisma generate command, because I'm using a MacBook with Apple Silicon (M2) chip, but inside Docker it runs alright without the -arm64
suffix.
I'll share the Docker logs with you below:
Server listening on port 8080
Calling http://127.0.0.1:39925/status (n=1)
Attempt 1/10 failed for status: Connection refused
Retrying after 81ms
Calling http://127.0.0.1:39925/status (n=2)
Attempt 2/10 failed for status: Connection refused
Retrying after 189ms
Calling http://127.0.0.1:39925/status (n=3)
Attempt 3/10 failed for status: Connection refused
Retrying after 324ms
Calling http://127.0.0.1:39925/status (n=4)
Attempt 4/10 failed for status: Connection refused
Retrying after 670ms
Calling http://127.0.0.1:39925/status (n=5)
Attempt 5/10 failed for status: Connection refused
Retrying after 1390ms
Calling http://127.0.0.1:39925/status (n=6)
Attempt 6/10 failed for status: Connection refused
Retrying after 3298ms
Calling http://127.0.0.1:39925/status (n=7)
Attempt 7/10 failed for status: Connection refused
Retrying after 7490ms
Calling http://127.0.0.1:39925/status (n=8)
Attempt 8/10 failed for status: Connection refused
Retrying after 12788ms
Calling http://127.0.0.1:39925/status (n=9)
Attempt 9/10 failed for status: Connection refused
Retrying after 28136ms
Calling http://127.0.0.1:39925/status (n=10)
Unhandled exception:
Connection refused
#0 IOClient.send (package:http/src/io_client.dart:94)
<asynchronous suspension>
#1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93)
<asynchronous suspension>
#2 _withClient (package:http/http.dart:166)
<asynchronous suspension>
#3 BinaryEngine._createEngineStatusValidator.<anonymous closure> (package:orm/binary_engine.dart:265)
<asynchronous suspension>
#4 _InternalRetry.call (package:orm/universal_engine.dart:298)
<asynchronous suspension>
#5 RetryOptions.retry (package:retry/retry.dart:131)
<asynchronous suspension>
#6 BinaryEngine._createProcess (package:orm/binary_engine.dart:189)
<asynchronous suspension>
#7 BinaryEngine.start (package:orm/binary_engine.dart:148)
<asynchronous suspension>
#8 UniversalEngine.request (package:orm/universal_engine.dart:59)
<asynchronous suspension>
#9 ModelDelegate._execute (package:orm/src/client/model_delegate.dart:40)
<asynchronous suspension>
#10 PrismaFluent.queryBuilder.<anonymous closure> (package:orm/src/client/prisma_fluent.dart:37)
<asynchronous suspension>
Note that my backend always connect to the database (almost of time not in the first try) if I run it using my physical machine, i.e. I only reproduced this behavior using Docker or Kubernetes
Do you know if it may happens with other databases inside Docker/Kubernetes? I prefer MongoDB (by MongoDB Atlas) because it has a free cluster in the cloud, but I can use another DB option. I'm just starting the development of my personal project.
@jdaibello I see your log is running a Dart AOT program normally, I mean you should manually run this binary file in node_modules/prisma/prisma-engine-xxx. I think you copied it into scratch
correctly.
Hi, good day.
I made a Dockerfile for running my Dart backend in containers (my objective is deploying the server by using Kubernetes on Digital Ocean) similar to the Dockerfile provided by the example in this repository, but my Dart server is not connecting to the MongoDB Atlas database (open for any connections) inside Docker (it can connect normally when running outside Docker).
My Dockerfile:
Obs: The command
RUN npx prisma db push
connect to MongoDB to push database changes.My docker-compose.yaml:
My schema.prisma:
My .env file:
And my bin/server.dart:
Any help is appreciated.