I’m deploying a Next.js + Postgres/Prism app and it fails because it can’t find the
The error during deployment happens when it tries to run
npx prisma migrate deploy from the
#12 3.531 error: Environment variable not found: DATABASE_URL. #12 3.531 --> schema.prisma:10 #12 3.531 | #12 3.531 9 | provider = "postgresql" #12 3.531 10 | url = env("DATABASE_URL")
DATABASE_URL is set in the secrets for the Next.js app:
$ fly secrets list NAME DIGEST CREATED AT DATABASE_URL <digest> 9m40s ago
I verify it by typing this:
$ fly ssh console Connecting to servername.internal... complete # echo $DATABASE_URL postgres://...
Dockerfile is the default one that Fly generated, but I added these two lines:
RUN npx prisma migrate deploy RUN npx prisma generate
fly.toml file is the default, generated one, except I changed the port from
The deployment does work if I hard-code the
DATABASE_URL in the
Dockerfile like this, but I don’t want to store the password in Git:
ENV DATABASE_URL postgres:://... RUN npx prisma migrate deploy RUN npx prisma generate
I tried deleting the Next app and Postgres database from Fly and recreating them, but the problem still exists on the new version.
Edit: I also tried adding the
DATABASE_URL as a secret to the builder app, but it failed there too.
Does anyone know why it isn’t working?