DATABASE_URL environment variable not found
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Environment variable not found: DATABASE_URL.
--> prisma/schema.prisma:8
|
7 | provider = "postgres"
8 | url = env("DATABASE_URL")
|
Validation Error Count: 1
[Context: getConfig]
anyone else hit this error before?
I am running a Dockerized Express API on an AWS EC2, and entered environment variables via the
-e tag in the docker run command.
This is all within the context of a CI/CD pipeline I'm setting up.
Currently debugging and digging around for a solution.
3 Replies
Hi @Alex DiGrazia
Can you add a step in your pipeline to echo the
DATABASE_URL
to ensure it's set correctly?
You may also waqnt to check that you don't wrap the environment variable in double quotation marks as observed in this previous discussionGitHub
error: Environment variable not found: DATABASE_URL. · prisma prism...
Bug description Hello. I'm struggling with connecting to a database running in the docker container alongside my main app (nestjs+prisma). I'm getting the following error: #0 9.627 Prisma s...
Hi Raphael, thanks for your response.
I think the problem was stemming from not having an ENV step in my Dockerfile.
My Dockerfile looks like this, and I think that by not having an ENV step in the build process, my Prisma Generate doesn't have a Database variable available to generate the client.
I'm very new to DevOps and Docker, and learning as I go.
As per a tutorial I was following, I was entering -e variables in the Docker run command, but I realize now that doesn't actually help me at all in building the image when my image needs the DB variable in order to generate the client.
Working through a solution in that vein now
SOLVED
Turns out what I needed to do was add
which initializes a build argument DATABASE_URL and then sets it as an environment variable so it will be availabe to subsequent steps in the Dockerfile, specifically
Then when in my Docker build step I include the
parameter.
So my build step passes the argument to the docker file like this
Thanks for the help @RaphaelEtim
Very happy to be newly part of the community.