This repository has been archived on 2026-06-15. You can view files and clone it, but cannot push or open issues or pull requests.
Files
MediaLore/Dockerfile
Garret Patti 0b03b937e0
All checks were successful
Build and Push Docker Image / build (push) Successful in 54s
update dockerfile
2026-04-14 08:31:30 -04:00

60 lines
1.9 KiB
Docker

# Stage 1: Install dependencies (with build tools for native modules)
FROM node:22-bookworm-slim AS deps
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci
# Stage 2: Build the Next.js application
FROM node:22-bookworm-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Stage 3: Production image
FROM node:22-bookworm-slim AS runner
WORKDIR /app
# Install ffmpeg for video thumbnail generation
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production
ENV PORT=3000
# Bind to all interfaces so the container port is reachable
ENV HOSTNAME=0.0.0.0
RUN mkdir -p /config
# Copy standalone Next.js output
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# COPY --from=builder /app/public ./public
# Copy native modules — Next.js standalone's file tracer does not follow
# .node binary files, so we copy these manually from the deps stage.
# Both are listed in serverExternalPackages and resolved at runtime via require().
COPY --from=deps /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
COPY --from=deps /app/node_modules/sharp ./node_modules/sharp
COPY --from=deps /app/node_modules/@img ./node_modules/@img
# tesseract.js loads its worker via worker_threads using a runtime-constructed path,
# so the standalone file tracer never discovers src/worker-script/node/. Copy the
# full package so that path resolves correctly at runtime.
COPY --from=deps /app/node_modules/tesseract.js ./node_modules/tesseract.js
COPY --from=deps /app/node_modules/tesseract.js-core ./node_modules/tesseract.js-core
# Create thumbnail cache directory (mounted as a volume in production)
RUN mkdir -p /app/.thumbnails
EXPOSE 3000
CMD ["node", "server.js"]