Move Prisma config to project root as .mjs for Prisma 7
- Move prisma.config.ts to prisma.config.mjs at project root - Use dynamic dotenv import (works in Docker without dotenv) - Add dotenv to devDependencies for local development - Install dotenv globally in Docker for migration support Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
053463b7e1
commit
8157531fba
|
|
@ -61,13 +61,14 @@ RUN chown nextjs:nodejs .next
|
|||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
# Copy Prisma (client and schema for migrations)
|
||||
# Copy Prisma (client, schema, and config for migrations)
|
||||
COPY --from=deps /app/node_modules/.prisma ./node_modules/.prisma
|
||||
COPY --from=deps /app/node_modules/@prisma ./node_modules/@prisma
|
||||
COPY prisma ./prisma/
|
||||
COPY prisma.config.mjs ./
|
||||
|
||||
# Install Prisma CLI globally for migrations
|
||||
RUN npm install -g prisma@7
|
||||
# Install Prisma CLI and dotenv globally for migrations
|
||||
RUN npm install -g prisma@7 dotenv
|
||||
|
||||
USER nextjs
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
"zustand": "^5.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dotenv": "^16.5.0",
|
||||
"@eslint/eslintrc": "^3.3.3",
|
||||
"@testing-library/react": "^16.3.1",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
// Load .env file for local development (silently skip if not available)
|
||||
try {
|
||||
const dotenv = await import('dotenv')
|
||||
dotenv.config()
|
||||
} catch {
|
||||
// dotenv not available (e.g., in Docker) - env vars passed directly
|
||||
}
|
||||
|
||||
const databaseUrl = process.env.DATABASE_URL
|
||||
|
||||
if (!databaseUrl) {
|
||||
throw new Error('DATABASE_URL environment variable is required')
|
||||
}
|
||||
|
||||
export default {
|
||||
schema: 'prisma/schema.prisma',
|
||||
migrations: {
|
||||
path: 'prisma/migrations',
|
||||
},
|
||||
datasource: {
|
||||
url: databaseUrl,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
import 'dotenv/config'
|
||||
import { defineConfig, env } from 'prisma/config'
|
||||
|
||||
export default defineConfig({
|
||||
schema: 'prisma/schema.prisma',
|
||||
migrations: {
|
||||
path: 'prisma/migrations',
|
||||
},
|
||||
datasource: {
|
||||
url: env('DATABASE_URL'),
|
||||
},
|
||||
})
|
||||
Loading…
Reference in New Issue