diff --git a/Dockerfile b/Dockerfile index 15559d7..500569a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,10 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production -# Build the application +# Generate Prisma Client (needs schema but not DATABASE_URL yet) +RUN npx prisma generate + +# Build the application (DATABASE_URL will be available via Coolify env vars) RUN npm run build # Production image, copy all the files and run next @@ -43,6 +46,11 @@ COPY --from=builder /app/public ./public COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +# Copy Prisma files for runtime +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma +COPY --from=builder /app/prisma ./prisma + USER nextjs EXPOSE 3000 diff --git a/package.json b/package.json index 0550af6..a279496 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "prisma generate && prisma db push --accept-data-loss && next build", + "build": "next build", "start": "next start", "lint": "eslint", "postinstall": "prisma generate", diff --git a/scripts/db-setup.sh b/scripts/db-setup.sh new file mode 100755 index 0000000..f7e7e8d --- /dev/null +++ b/scripts/db-setup.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Run database migrations at container startup +# This ensures DATABASE_URL is available from Coolify env vars + +echo "Running Prisma DB setup..." +npx prisma db push --accept-data-loss --skip-generate +echo "Database setup complete!"