Update Dockerfile to improve database handling and entrypoint script: Change DATABASE_URL for build environment, streamline Prisma commands, and implement a custom entrypoint script for better migration management and application startup.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m25s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m25s
This commit is contained in:
31
Dockerfile
31
Dockerfile
@@ -19,10 +19,8 @@ RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
ENV DATABASE_URL="file:/app/data/dev.db"
|
||||
RUN pnpm prisma generate && \
|
||||
pnpm prisma migrate deploy && \
|
||||
pnpm prisma db push
|
||||
ENV DATABASE_URL="file:/tmp/build.db"
|
||||
RUN pnpm prisma generate
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN pnpm build
|
||||
@@ -49,22 +47,35 @@ COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||
COPY --from=builder /app/next.config.js ./next.config.js
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
ENV DATABASE_URL="file:/tmp/build.db"
|
||||
|
||||
# Installer seulement les dépendances de production puis générer Prisma Client
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
pnpm install --frozen-lockfile --prod && \
|
||||
pnpm dlx prisma generate
|
||||
|
||||
ENV DATABASE_URL="file:/app/data/dev.db"
|
||||
|
||||
# Nettoyer les dépendances de développement
|
||||
RUN pnpm prune --prod
|
||||
|
||||
|
||||
# Create data directory for SQLite database and uploads directories
|
||||
RUN mkdir -p /app/data /app/public/uploads /app/public/uploads/backgrounds && \
|
||||
chown -R nextjs:nodejs /app/data /app/public/uploads
|
||||
|
||||
RUN echo '#!/bin/sh' > /app/entrypoint.sh && \
|
||||
echo 'set -e' >> /app/entrypoint.sh && \
|
||||
echo 'mkdir -p /app/data' >> /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 'exec pnpm start' >> /app/entrypoint.sh && \
|
||||
chmod +x /app/entrypoint.sh && \
|
||||
chown nextjs:nodejs /app/entrypoint.sh
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
ENV DATABASE_URL="file:/app/data/dev.db"
|
||||
|
||||
ENTRYPOINT ["pnpm", "start"]
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
Reference in New Issue
Block a user