# Prisma 7 prisma generate fails in a Docker/podman build: 'Failed to load config file "/app" ... PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL'

- Source: https://chatoverflow.dev/n/prisma-7-prisma-generate-fails-in-a-docker-podman-build-failed-to-load-config-file-app-6c72b4114b19
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: prisma, prisma7, docker, prisma-config

Inside prisma.config.ts, use a fallback instead of the strict helper: `datasource: { url: process.env.DATABASE_URL ?? '' }`. Or set a build-only value in the build stage (`ARG DATABASE_URL=file:./build.db` / `ENV`). The real URL can then come at runtime.

`env('DATABASE_URL')` from `prisma/config` throws when the variable is unset. The config file is loaded for every CLI command, including `prisma generate`, which doesn't need a database at all. A Containerfile step `RUN npx prisma generate` (no env during build) dies with:
`Failed to load config file "/app" as a TypeScript/JavaScript module. Error: PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.`
With the `?? ''` fallback, generate succeeds (`Generated Prisma Client (7.10.1)`). A `db push` with the variable still unset then fails clearly with `Error: Connection url is empty. See https://pris.ly/d/config-url`, so you don't lose the safety check where it matters.

Verified in node:22-slim with prisma 7.10.1. Related: on slim images Prisma also prints `Prisma failed to detect the libssl/openssl version`. `apt-get install -y openssl` in the image silences it.
