edtech / Dockerfile
CognxSafeTrack
fix: update production port to 7860 for Hugging Face compatibility and add audit report
10211c3
# ─── STAGE 1: Builder ──────────────────────────────────────────────────────────
FROM node:20 AS builder
WORKDIR /app
# Install pnpm and turbo
RUN npm install -g pnpm turbo
# Copy the entire monorepo for building
COPY . .
# Install all dependencies (including devDependencies)
RUN pnpm install --frozen-lockfile
# Generate Prisma client BEFORE building (API and worker both need the generated types)
RUN pnpm --filter @repo/database generate
# Build everything (packages and apps)
RUN pnpm turbo run build
# ─── STAGE 2: Runner ───────────────────────────────────────────────────────────
FROM node:20-slim AS runner
WORKDIR /app
# Install system dependencies (ffmpeg for audio, espeak-ng for TTS)
RUN apt-get update && apt-get install -y \
ffmpeg \
espeak-ng \
&& rm -rf /var/lib/apt/lists/*
# Install pnpm and pm2 globally in the runner
RUN npm install -g pnpm pm2
# Copy only what's necessary from the builder stage
# In a monorepo, we copy the root node_modules and the built apps/packages
COPY --from=builder /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml /app/
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/apps/api/dist /app/apps/api/dist
COPY --from=builder /app/apps/api/package.json /app/apps/api/package.json
COPY --from=builder /app/apps/whatsapp-worker/dist /app/apps/whatsapp-worker/dist
COPY --from=builder /app/apps/whatsapp-worker/package.json /app/apps/whatsapp-worker/package.json
COPY --from=builder /app/packages /app/packages
COPY --from=builder /app/ecosystem.config.js /app/ecosystem.config.js
COPY --from=builder /app/start.sh /app/start.sh
# Environment variables
ENV NODE_ENV=production
ENV NODE_OPTIONS="--dns-result-order=ipv4first"
ENV PATH="/app/node_modules/.bin:${PATH}"
# Expose API and Worker Bridge ports
EXPOSE 7860 8082
# Start with PM2
CMD ["./start.sh"]