5 PRD gaps fixed: 1. Zod validation on all API inputs (§5.2) — 26 files, 27 safeParse 2. Rate limiting on public endpoints (§5.6) — 6 scopes, 7 endpoints 3. Custom fields JSONB with schema (§5.5) — 2 models, 10 seed defs 4. CSP + security headers (§5.6) — 7 headers via next.config.ts 5. ESLint module boundary rule (§5.4) — no-restricted-imports 0 TS errors, ESLint clean.
54 lines
1.5 KiB
Docker
Executable File
54 lines
1.5 KiB
Docker
Executable File
# AOS — Agency Operating System
|
|
# Production Dockerfile (PRD §5.7: Docker/Podman deployment)
|
|
# Multi-stage build: install → build → run
|
|
|
|
# --- Stage 1: Install dependencies ---
|
|
FROM node:22-slim AS deps
|
|
WORKDIR /app
|
|
COPY package.json bun.lock ./
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# --- Stage 2: Build ---
|
|
FROM node:22-slim AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV DATABASE_URL="file:/app/db/custom.db"
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# --- Stage 3: Runner ---
|
|
FROM node:22-slim AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
# Install only what's needed for production
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
sqlite3 curl && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy built app
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
|
|
|
# Create data directory for SQLite
|
|
RUN mkdir -p /app/db /app/data
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:3000/api/health || exit 1
|
|
|
|
EXPOSE 3000
|
|
|
|
# Run migrations + start server
|
|
CMD ["sh", "-c", "npx prisma db push --accept-data-loss && node server.js"]
|