FROM node:22-alpine

RUN apk add --no-cache \
    nss freetype freetype-dev harfbuzz ca-certificates ttf-freefont \
    libstdc++ dbus-glib xvfb xauth wget curl yt-dlp

RUN npm install -g @askjo/camofox-browser@1.13.1
RUN npx playwright install firefox

EXPOSE 9377

ENV CAMOFOX_PORT=9377
ENV CAMOFOX_REWRITE_LOOPBACK_URLS=true
ENV CAMOFOX_LOOPBACK_HOST_ALIAS=host.docker.internal
ENV DISPLAY=:99

CMD Xvfb :99 -screen 0 1920x1080x24 & sleep 0.5 && camofox-browser
