Fix: Install OpenSSL and fix Prisma permission issues in Docker

This commit is contained in:
duongcamcute
2026-01-15 23:33:20 +07:00
parent 1734385e04
commit 2db3f2759e
2 changed files with 6 additions and 4 deletions

View File

@@ -24,6 +24,11 @@ RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
# Install OpenSSL (required for Prisma) and Prisma CLI globally directly as root
# We install prisma@5.22.0 to match project dependencies
RUN apk add --no-cache openssl && \
npm install -g prisma@5.22.0
WORKDIR /app
ENV NODE_ENV production
@@ -42,9 +47,6 @@ COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
# Copy entrypoint script
COPY --from=builder --chown=nextjs:nodejs /app/docker-entrypoint.sh ./
# Install prisma CLI explicitly in the runner so we can migrate
RUN npm install -g prisma@5.22.0
# Set permissions
RUN chmod +x ./docker-entrypoint.sh

View File

@@ -4,7 +4,7 @@ set -e
# Chạy migration database (tạo bảng nếu chưa có)
echo "Running database migrations..."
npx prisma migrate deploy
prisma migrate deploy
# Chạy ứng dụng Next.js
echo "Starting Next.js application..."