From dedec653ee08fc6dbe7ca149be49eecb91c15ec1 Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sun, 20 Sep 2026 18:30:23 +0200 Subject: [PATCH] Fix Prisma openssl dependency and add docker-entrypoint to run migrations automatically --- Dockerfile | 11 +++++++++-- docker-entrypoint.sh | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 69e3e7f..50e8b07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ # --- Stage 1: Dependencies --- FROM node:20.18-alpine AS deps -RUN apk add --no-cache libc6-compat python3 make g++ +RUN apk add --no-cache libc6-compat python3 make g++ openssl WORKDIR /app COPY package.json package-lock.json ./ @@ -13,6 +13,7 @@ RUN npm ci # --- Stage 2: Build --- FROM node:20.18-alpine AS builder +RUN apk add --no-cache openssl WORKDIR /app COPY --from=deps /app/node_modules ./node_modules @@ -37,6 +38,7 @@ RUN apk add --no-cache \ ffmpeg \ vips-dev \ wget \ + openssl \ && addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs @@ -49,12 +51,17 @@ COPY --from=builder /app/prisma ./prisma # Copy additional node_modules needed at runtime (not bundled by standalone) COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma +COPY --from=builder /app/node_modules/prisma ./node_modules/prisma COPY --from=builder /app/node_modules/bullmq ./node_modules/bullmq COPY --from=builder /app/node_modules/ioredis ./node_modules/ioredis COPY --from=builder /app/node_modules/archiver ./node_modules/archiver COPY --from=builder /app/node_modules/bcrypt ./node_modules/bcrypt COPY --from=builder /app/node_modules/sharp ./node_modules/sharp +# Copy entrypoint +COPY docker-entrypoint.sh ./ +RUN chmod +x docker-entrypoint.sh + # Create directories for media and cache RUN mkdir -p /media /cache/thumbnails /cache/previews /cache/download \ && chown -R nextjs:nodejs /cache @@ -69,4 +76,4 @@ ENV HOSTNAME="0.0.0.0" HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD wget -qO- http://localhost:3000/api/health || exit 1 -CMD ["node", "server.js"] +CMD ["./docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..c34413e --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +echo "[Entrypoint] Waiting for database..." +# Wait for postgres to be ready (optional, but good practice) +# We just rely on Docker Compose depends_on with condition: service_healthy, so it should be ready. + +echo "[Entrypoint] Applying database schema..." +npx prisma db push --accept-data-loss --skip-generate + +echo "[Entrypoint] Starting Next.js application..." +exec node server.js