Fix: Make all env vars optional for Docker build time
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s

This commit is contained in:
Ahmed Darrazi 2025-12-05 23:52:11 +01:00
parent f80c3a1598
commit 477ac67703
2 changed files with 4 additions and 12 deletions

View File

@ -6,6 +6,6 @@ export default {
dialect: "postgresql", dialect: "postgresql",
out: "./lib/db/migrations", out: "./lib/db/migrations",
dbCredentials: { dbCredentials: {
url: env.DATABASE_URL, url: env.DATABASE_URL ?? "",
} }
} satisfies Config; } satisfies Config;

View File

@ -7,18 +7,10 @@ export const env = createEnv({
NODE_ENV: z NODE_ENV: z
.enum(["development", "test", "production"]) .enum(["development", "test", "production"])
.default("development"), .default("development"),
DATABASE_URL: z.string().min(1), DATABASE_URL: z.string().optional(),
NEXTAUTH_SECRET: process.env.NODE_ENV === "production" NEXTAUTH_SECRET: z.string().optional(),
? z.string().min(1) NEXTAUTH_URL: z.string().optional(),
: z.string().optional(),
NEXTAUTH_URL: z.preprocess(
// This makes Vercel deployments not fail if you don't set NEXTAUTH_URL
// Since NextAuth.js automatically uses the VERCEL_URL if present.
(str) => process.env.VERCEL_URL ?? str,
// VERCEL_URL doesn't include `https` so it cant be validated as a URL
process.env.VERCEL_URL ? z.string().min(1) : z.string().url()
),
// Azure AD (Microsoft Entra ID) - optional in development // Azure AD (Microsoft Entra ID) - optional in development
AZURE_AD_CLIENT_ID: z.string().optional(), AZURE_AD_CLIENT_ID: z.string().optional(),