# Defentra LinkedIn Agent — production image.
# Uses the distro's Chromium for Puppeteer (smaller, reliable) instead of the
# bundled download.
FROM node:22-bookworm-slim

# Tell Puppeteer to use the system Chromium and skip its own download.
ENV PUPPETEER_SKIP_DOWNLOAD=1 \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium \
    NODE_ENV=production

RUN apt-get update && apt-get install -y --no-install-recommends \
      chromium ca-certificates fonts-liberation fonts-noto-color-emoji \
      libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 libdrm2 libgbm1 \
      libgtk-3-0 libnspr4 libnss3 libxcomposite1 libxdamage1 libxfixes3 \
      libxkbcommon0 libxrandr2 libasound2 \
 && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev || npm install --omit=dev
COPY . .

# data/ holds db.json + rendered posters; mount a volume to persist it.
VOLUME ["/app/data"]
EXPOSE 8099
CMD ["node", "src/index.js"]
