# Pin to the puppeteer image that matches puppeteer-core in package.json.
# This image ships the matching Chrome build under /home/pptruser/.cache/puppeteer.
FROM ghcr.io/puppeteer/puppeteer:25.1.0

USER root

# Install Bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"

WORKDIR /app

# Install dependencies (lockfile committed → reproducible builds)
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

# Copy source
COPY . .

# puppeteer-core never downloads Chrome; the binary comes from the base image.
# Chrome is discovered at runtime by findChrome() so we don't pin a brittle path.
ENV PUPPETEER_SKIP_DOWNLOAD=true

EXPOSE 8787

CMD ["bun", "run", "src/index.ts"]
