Open christianto88 opened 2 years ago
Try adding these lines:
ARG DATABASE_URL
ENV DATABASE_URL ${DATABASE_URL}
Hi @christianto88 thank you for reporting this
Just to confirm,
railway vars
include your DATABASE_URL?railway up
do you get the same issue if you deploy via the UI?@abuuzayr Yes it is on railway vars
. I tried deploying using trigger on one github branches, it also failed
This error shows up for me whenever I upgrade to Prisma@^3 and run blitz build
.If a valid DATABASE_URL
is present, then it will build fine, but that's a flawed solution IMO.
It shouldn't have to be present to build, and one could argue is a security risk to expose that variable to the bundler. That should only be a runtime variable/secret that even the Dockerfile shouldn't have to know about. When I run my app in production it gets injected as a K8s secret. For now I'm still on prisma@2.30.3 until this gets resolved.
This error shows up for me whenever I upgrade to Prisma@^3 and run
blitz build
.If a validDATABASE_URL
is present, then it will build fine, but that's a flawed solution IMO.It shouldn't have to be present to build, and one could argue is a security risk to expose that variable to the bundler. That should only be a runtime variable/secret that even the Dockerfile shouldn't have to know about. When I run my app in production it gets injected as a K8s secret. For now I'm still on prisma@2.30.3 until this gets resolved.
@jcmcneal Is there an open issue for that in prisma repo?
A workaround that worked on one of my projects is to provide a dummy DATABASE_URL to blitz. I used DATABASE_URL=postgresql://postgres:postgres@localhost:5432/main?schema=public
and the build succeeded in GitHub action without any Postgres instance running on localhost:5432
.
It seems to me that blitz might somehow always trigger Prisma to run during build without running any query? This doesn't happen when I'm using Next with Prisma.
That's insightful information @chrsep, thank you! I will try using the dummy variable in my dockerfile and see how it goes.
If Next doesn't have this issue with Prisma, but Blitz does, then you may be right about it triggering Prisma to connect to the db unintentionally.
@beerose I didn't find any open issues in the Prisma repo about this. However, I think it's related to how Blitz works with Prisma@^3.
Do you have static pages that make calls to DB? If yes, that could cause the issue with the missing DB URL during the build.
Otherwise, I haven't yet found anything internally that could cause this issue. We changed the Prisma version in new app templates from 2.x to 3.x but that didn't require any changes in Blitz code. I suppose something changed with prisma generate
that it started requiring database URL?
I have an app running on Railway with Blitz v0.44.3 and a Dockerfile very similar to this one. I remember using the trick I mentioned earlier because there has to be a DATABASE_URL
on buildtime.
Btw, that may need to be fixed. It also happened to me when trying to apply the same method enhancedPrisma
uses to other clients and it's kinda dangerous
What is the problem?
Deployment on Railway failed because cannot find environment variable DATABASE_URL. I am deploying using Dockerfile and the error occurs when running blitz build
Found a workaround by adding ARG DATABASE_URL to my Dockerfile
Paste all your error logs here:
Paste all relevant code snippets here:
Dockerfile before upgrading blitz ( worked previously )
Package.json before upgrading blitz ( worked previously )
New package.json
What are detailed steps to reproduce this?
railway up
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response