Update Docker configuration for Prisma migrations: Comment out migrations volume in docker-compose.yml for production use, and add checks in Dockerfile to verify the presence of migrations during build and entrypoint execution.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 14s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 14s
This commit is contained in:
15
Dockerfile
15
Dockerfile
@@ -19,6 +19,9 @@ 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
|
||||
|
||||
@@ -45,10 +48,10 @@ COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||
COPY --from=builder /app/next.config.js ./next.config.js
|
||||
RUN mkdir -p /app/prisma/migrations
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/schema.prisma ./prisma/schema.prisma
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/migrations ./prisma/migrations
|
||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||
# 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"
|
||||
|
||||
@@ -65,7 +68,9 @@ RUN echo '#!/bin/sh' > /app/entrypoint.sh && \
|
||||
echo 'set -e' >> /app/entrypoint.sh && \
|
||||
echo 'mkdir -p /app/public/uploads' >> /app/entrypoint.sh && \
|
||||
echo 'mkdir -p /app/public/uploads/backgrounds' >> /app/entrypoint.sh && \
|
||||
echo 'pnpm dlx prisma migrate deploy || true' >> /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 'exec pnpm start' >> /app/entrypoint.sh && \
|
||||
chmod +x /app/entrypoint.sh && \
|
||||
chown nextjs:nodejs /app/entrypoint.sh
|
||||
|
||||
Reference in New Issue
Block a user