FROM mcr.microsoft.com/playwright:v1.60.0-noble

WORKDIR /app

ENV NODE_ENV=production
ENV ARCHIVE_PATH=/archives
ENV DISPLAY=:99
ENV ARCHIVE_WORKER_XVFB=1
ENV ARCHIVE_WORKER_VIEWPORT=1366x768x24

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      dumb-init \
      x11vnc \
      xvfb && \
    rm -rf /var/lib/apt/lists/*

COPY package.json package-lock.json ./
RUN npm ci --omit=dev

COPY . .
RUN mkdir -p /archives && chmod 0777 /archives

VOLUME ["/archives"]
EXPOSE 5733

ENTRYPOINT ["dumb-init", "--", "/app/scripts/archive-worker-entrypoint.sh"]
CMD ["help"]
