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
Some checks failed
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 2m4s
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -6,7 +6,7 @@ FROM node:20-alpine AS deps
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies for native modules
|
# 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 files
|
||||||
COPY package.json bun.lockb* ./
|
COPY package.json bun.lockb* ./
|
||||||
@@ -22,6 +22,9 @@ RUN bun install --frozen-lockfile
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install openssl for Prisma
|
||||||
|
RUN apk add --no-cache openssl
|
||||||
|
|
||||||
# Copy dependencies from deps stage
|
# Copy dependencies from deps stage
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -32,9 +35,10 @@ RUN npm install -g bun
|
|||||||
# Set environment variables for build
|
# Set environment variables for build
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV DATABASE_URL="file:./dev.db"
|
||||||
|
|
||||||
# Generate Prisma client
|
# Generate Prisma client using npx (more reliable in Docker)
|
||||||
RUN bun run db:generate
|
RUN npx prisma generate --schema=./prisma/schema.prisma
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
@@ -43,13 +47,20 @@ RUN bun run build
|
|||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install openssl for Prisma
|
||||||
|
RUN apk add --no-cache openssl
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV DATABASE_URL="file:./data/dev.db"
|
||||||
|
|
||||||
# Create non-root user for security
|
# Create non-root user for security
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
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 necessary files from builder
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
|
|||||||
Reference in New Issue
Block a user