diff --git a/Dockerfile b/Dockerfile index 3090aab..9b39c34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,9 +19,6 @@ RUN corepack enable && corepack prepare pnpm@latest --activate COPY --from=deps /app/node_modules ./node_modules COPY . . -# Vérifier que les migrations sont bien présentes -RUN ls -la /app/prisma/migrations || echo "WARNING: Migrations directory not found" - ENV DATABASE_URL="postgresql://user:pass@localhost:5432/db" RUN pnpm prisma generate @@ -50,8 +47,6 @@ COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml COPY --from=builder /app/next.config.js ./next.config.js # Copier le répertoire prisma complet (schema + migrations + config) COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma -# Vérifier que les migrations ont bien été copiées -RUN ls -la /app/prisma/migrations || (echo "ERROR: Migrations not found after COPY" && exit 1) ENV DATABASE_URL="postgresql://user:pass@localhost:5432/db" @@ -70,7 +65,14 @@ RUN echo '#!/bin/sh' > /app/entrypoint.sh && \ echo 'mkdir -p /app/public/uploads/backgrounds' >> /app/entrypoint.sh && \ echo 'echo "Checking migrations..."' >> /app/entrypoint.sh && \ echo 'ls -la /app/prisma/migrations || echo "Migrations directory not found"' >> /app/entrypoint.sh && \ - echo 'pnpm dlx prisma migrate deploy' >> /app/entrypoint.sh && \ + echo 'if [ -z "$DATABASE_URL" ]; then' >> /app/entrypoint.sh && \ + echo ' echo "ERROR: DATABASE_URL is not set"' >> /app/entrypoint.sh && \ + echo ' exit 1' >> /app/entrypoint.sh && \ + echo 'fi' >> /app/entrypoint.sh && \ + echo 'echo "DATABASE_URL is set (checking schema.prisma)..."' >> /app/entrypoint.sh && \ + echo 'ls -la /app/prisma/schema.prisma || echo "ERROR: schema.prisma not found"' >> /app/entrypoint.sh && \ + echo 'export DATABASE_URL' >> /app/entrypoint.sh && \ + echo 'cd /app && pnpm dlx prisma migrate deploy --schema=./prisma/schema.prisma' >> /app/entrypoint.sh && \ echo 'exec pnpm start' >> /app/entrypoint.sh && \ chmod +x /app/entrypoint.sh && \ chown nextjs:nodejs /app/entrypoint.sh diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 052a4e7..6d3f13f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -5,6 +5,7 @@ generator client { datasource db { provider = "postgresql" + url = env("DATABASE_URL") } model User {