Fix Prisma openssl dependency and add docker-entrypoint to run migrations automatically
This commit is contained in:
1 parent
134ba81cd5
commit
dedec653ee
2 files changed
+21
-2
No files matched your search
+9
-2
@@ -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"]
|
||||
@@ -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
|
||||
Reference in new issue
Block a user