69 lines
1.6 KiB
Docker
69 lines
1.6 KiB
Docker
# ============================================================
|
|
# STAGE 1: Build Frontend + Backend
|
|
# ============================================================
|
|
FROM node:22-bookworm AS builder
|
|
|
|
# Install system dependencies for sharp and pdf processing
|
|
RUN apt-get update && apt-get install -y \
|
|
python3 \
|
|
make \
|
|
g++ \
|
|
gcc \
|
|
libvips-dev \
|
|
poppler-utils \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm globally
|
|
RUN npm install -g pnpm@10.4.1 node-gyp
|
|
|
|
# Copy package files
|
|
COPY package.json pnpm-lock.yaml ./
|
|
COPY patches/ ./patches/
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build frontend + backend
|
|
RUN pnpm build
|
|
|
|
# ============================================================
|
|
# STAGE 2: Production image
|
|
# ============================================================
|
|
FROM node:22-bookworm-slim AS production
|
|
|
|
# Install runtime dependencies only
|
|
RUN apt-get update && apt-get install -y \
|
|
poppler-utils \
|
|
libvips42 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy node_modules from builder (already compiled, including sharp native binaries)
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
# Copy built assets from builder
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/client/dist ./client/dist
|
|
|
|
# Copy package.json (needed for module resolution)
|
|
COPY package.json ./
|
|
|
|
# Copy drizzle migrations
|
|
COPY drizzle/ ./drizzle/
|
|
COPY drizzle.config.ts ./
|
|
|
|
# Create uploads directory
|
|
RUN mkdir -p /app/uploads
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "dist/index.js"]
|