Fix Docker build: use npx prisma generate and multi-stage build
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 2m4s

This commit is contained in:
2026-03-25 17:47:27 +00:00
parent 3386ffc41e
commit 5e9f560f26

View File

@@ -6,7 +6,7 @@ FROM node:20-alpine AS deps
WORKDIR /app
# Install dependencies for native modules
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache libc6-compat openssl
# Copy package files
COPY package.json bun.lockb* ./
@@ -22,6 +22,9 @@ RUN bun install --frozen-lockfile
FROM node:20-alpine AS builder
WORKDIR /app
# Install openssl for Prisma
RUN apk add --no-cache openssl
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
COPY . .
@@ -32,9 +35,10 @@ RUN npm install -g bun
# Set environment variables for build
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
ENV DATABASE_URL="file:./dev.db"
# Generate Prisma client
RUN bun run db:generate
# Generate Prisma client using npx (more reliable in Docker)
RUN npx prisma generate --schema=./prisma/schema.prisma
# Build the application
RUN bun run build
@@ -43,13 +47,20 @@ RUN bun run build
FROM node:20-alpine AS runner
WORKDIR /app
# Install openssl for Prisma
RUN apk add --no-cache openssl
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL="file:./data/dev.db"
# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Create data directory for SQLite
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
# Copy necessary files from builder
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./