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 --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
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"
|
ENV DATABASE_URL="postgresql://user:pass@localhost:5432/db"
|
||||||
RUN pnpm prisma generate
|
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/package.json ./package.json
|
||||||
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
|
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||||
COPY --from=builder /app/next.config.js ./next.config.js
|
COPY --from=builder /app/next.config.js ./next.config.js
|
||||||
RUN mkdir -p /app/prisma/migrations
|
# Copier le répertoire prisma complet (schema + migrations + config)
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/schema.prisma ./prisma/schema.prisma
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/migrations ./prisma/migrations
|
# Vérifier que les migrations ont bien été copiées
|
||||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
RUN ls -la /app/prisma/migrations || (echo "ERROR: Migrations not found after COPY" && exit 1)
|
||||||
|
|
||||||
ENV DATABASE_URL="postgresql://user:pass@localhost:5432/db"
|
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 'set -e' >> /app/entrypoint.sh && \
|
||||||
echo 'mkdir -p /app/public/uploads' >> /app/entrypoint.sh && \
|
echo 'mkdir -p /app/public/uploads' >> /app/entrypoint.sh && \
|
||||||
echo 'mkdir -p /app/public/uploads/backgrounds' >> /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 && \
|
echo 'exec pnpm start' >> /app/entrypoint.sh && \
|
||||||
chmod +x /app/entrypoint.sh && \
|
chmod +x /app/entrypoint.sh && \
|
||||||
chown nextjs:nodejs /app/entrypoint.sh
|
chown nextjs:nodejs /app/entrypoint.sh
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
# Persist uploaded images (avatars and backgrounds)
|
# Persist uploaded images (avatars and backgrounds)
|
||||||
- ${UPLOADS_PATH:-./public/uploads}:/app/public/uploads
|
- ${UPLOADS_PATH:-./public/uploads}:/app/public/uploads
|
||||||
- ./prisma/migrations:/app/prisma/migrations
|
# Migrations: décommenter uniquement en développement local pour modifier les migrations sans rebuild
|
||||||
|
# En production, les migrations sont incluses dans l'image Docker
|
||||||
|
# - ./prisma/migrations:/app/prisma/migrations
|
||||||
depends_on:
|
depends_on:
|
||||||
got-postgres:
|
got-postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
Reference in New Issue
Block a user