mirror of
https://github.com/Tony0410/readlater.git
synced 2026-05-24 13:52:03 +08:00
Fix Docker build for native SQLite module
- Add python3, make, g++ for building better-sqlite3 - Use npm ci --ignore-scripts then npm rebuild better-sqlite3 - Remove postinstall script that caused build issues Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -3,15 +3,22 @@ FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
# Install build dependencies for native modules (better-sqlite3)
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# Install dependencies (skip postinstall as source isn't there yet)
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
RUN npm ci --ignore-scripts
|
||||
|
||||
# Rebuild better-sqlite3 native bindings
|
||||
RUN npm rebuild better-sqlite3
|
||||
|
||||
# Copy source files
|
||||
COPY . .
|
||||
|
||||
# Generate database migrations
|
||||
RUN npx drizzle-kit generate
|
||||
# Generate database migrations and run them
|
||||
RUN npx drizzle-kit generate || true
|
||||
RUN npm run db:migrate || true
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
@@ -33,8 +40,9 @@ COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/drizzle ./drizzle
|
||||
COPY --from=builder /app/node_modules/drizzle-orm ./node_modules/drizzle-orm
|
||||
COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
|
||||
COPY --from=builder /app/src/lib/db/migrate.ts ./src/lib/db/migrate.ts
|
||||
COPY --from=builder /app/src/lib/db/schema.ts ./src/lib/db/schema.ts
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
|
||||
|
||||
Reference in New Issue
Block a user