Comments (13)
https://github.com/odroe/prisma-dart/blob/main/example/simple/Dockerfile Maybe it will help you
In the
simple
example it fails when it runs, because using SQLite in thescratch
benchmark image seems to be a bit of a problem, and my attempts to connect to MySQL and PG are both successful.
from prisma-dart.
The problem seems to be in your Dockerfile where you did not generate and copy the query engine binary.
Usually to Dockerize you need to set the PRISMA_QUERY_ENGINE_BINARY
environment variable in the Dockerfile (you can not set it, it is stored in .dart_tool/prisma/query-engine
by default), and then copy it to the same directory as your compiled Dart file.
The following is the normal copy process:
dart compiler exe <app>.dart -o /app/bin/<app>
# Compile your app executable filedart run orm precache -t query
# Predownload prisma query enginecp .dart_tool/prisma/query-engine /app/bin/
# Copy query engine to /app/bin/ dir
from prisma-dart.
Problem still exists after I added copy and generate steps to my dockerfile
# Official Dart image: https://hub.docker.com/_/dart
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.17)
FROM dart:stable AS build
WORKDIR /app
# Copy Dependencies
# Install Dependencies
# Resolve app dependencies.
COPY pubspec.* ./
RUN dart pub get
# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart run orm generate
RUN dart compile exe bin/server.dart -o bin/server
RUN dart run orm precache -t query
COPY .dart_tool/prisma/query-engine /app/bin/
# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
# Start server.
CMD ["/app/bin/server"]
from prisma-dart.
Thanks @medz! Now it looks like the problem with query-engine has been resolved. However, there is another issue:
build-server-1 | PrismaClientInitializationError:
build-server-1 | message: Failed to start the query engine: Connection refused
build-server-1 | errorCode: null
build-server-1 | clientVersion: 2.4.0
My first guess was that I have wrong connection uri in the scheme.prisma:
datasource db {
provider = "postgresql"
url = "postgres://app_user:password@localhost:5432/app_db?schema=public"
}
but it looks good.
Here's also my docker-compose file
version: '3'
services:
server:
image: app/app_server
ports:
- "8080:8080"
depends_on:
- db
links:
- db:db
networks:
- pgnetwork
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_DB: app_db
POSTGRES_USER: app_user
POSTGRES_PASSWORD: password
networks:
- pgnetwork
# Uncomment this if you want to persist the data.
# volumes:
# - "./pgdata:/var/lib/postgresql/data"
networks:
pgnetwork:
driver: bridge
from prisma-dart.
@jakub-stefaniak Your DATABASE_URL is indeed wrong, I'm not familiar with compose so I'm not sure how to solve your problem. Since I have postgres installed locally I have no problem connecting to my local postgres in the container.
from prisma-dart.
You can try replacing the URLs in schema.prisma with environment variables, and then configuring the correct environment variables in the compose configuration file may solve it.
from prisma-dart.
Maybe something to do with SSL, I'll keep testing it.
from prisma-dart.
Maybe it's really about SSL https://github.com/dart-lang/dart-docker/blob/main/Dockerfile-debian.template#L36
from prisma-dart.
@jakub-stefaniak I rewrote the Dockerfile through ubuntu:latest and it seems to solve the problem, I guess the scratch benchmark image is missing something necessary for the Prisma query engine. At present, through your error message, I presume it is SSL (OpenSSL or LibSSL). It seems we can fix it by manually installing an SSL for the sights.
see: https://github.com/odroe/prisma-dart/blob/main/example/simple/Dockerfile.ubuntu
from prisma-dart.
from prisma-dart.
@jakub-stefaniak Has this been resolved? Is there any further help needed, the result of my current tests is that OpenSSL needs to be installed. Unable to connect because the target image does not have OpenSSL or LibSSL.
from prisma-dart.
Thanks @medz! Now it looks like the problem with query-engine has been resolved. However, there is another issue:
build-server-1 | PrismaClientInitializationError: build-server-1 | message: Failed to start the query engine: Connection refused build-server-1 | errorCode: null build-server-1 | clientVersion: 2.4.0
PrismaClientInitializationError:
message: Failed to start the query engine: Connection refused
errorCode: null
clientVersion: 2.4.5
#0 BinaryEngine._createProcess (package:orm/src/engine_core/binary/binary_engine_io.dart:441:7)
<asynchronous suspension>
#1 BinaryEngine.start (package:orm/src/engine_core/binary/binary_engine_io.dart:333:17)
<asynchronous suspension>
#2 BinaryEngine.request (package:orm/src/engine_core/binary/binary_engine_io.dart:290:5)
<asynchronous suspension>
#3 ModelDelegate.findMany (package:package_name/prisma_client.dart:55755:42)
<asynchronous suspension>
...
Same error here. The database is PlanetScale, so I don't have any Docker compose file to set up with SSL or other...
Running the Dart Server locally I have no problems, but in staging/production gives me that error (the connection strings are the same).
@medz Anything to suggest?
from prisma-dart.
@jakub-stefaniak https://github.com/odroe/prisma-dart/blob/main/example/simple/Dockerfile
from prisma-dart.
Related Issues (20)
- Generation error with array of enum HOT 4
- If the type in .prisma is primitive list type like Int[], then the generated fromJson will cause error: HOT 2
- Document the use of multiple schemas in the same project.
- generator error in orm: ^3.4.8
- Joins, include and select HOT 3
- Dart Wrapper for the Prisma Library HOT 1
- Generated models have optional properties when defined as required in schema HOT 3
- Prisma engine architecture mismatch HOT 10
- Npx Prisma Generate Fails with Orm 4.0.0 HOT 3
- generated_dart_client errors HOT 1
- scehma in Windows production source code contains newline characters causing exceptions HOT 29
- Enhancing the model with information HOT 11
- why don't Json HOT 2
- v4.x generates nullable attributes for non-nullable fields HOT 2
- Wrong generate model, why? HOT 2
- Prisma binary query engine not ready HOT 10
- prisma-query-engine is not closing when the program is finished HOT 1
- Dependency Dashboard
- Error updating field with null
- Generated toJson() method not encoding DateTime and Enum types correctly for JSON responses
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-dart.