diff --git a/Dockerfile b/Dockerfile index 3b65d6a..27a5429 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,13 @@ ENV RESOLUTION=1080x720 # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer # installs, work. RUN apt-get update \ - && apt-get install -y wget gnupg tightvncserver xfce4 xfce4-goodies xfonts-base dbus-x11 \ + && apt-get install -y wget gnupg tightvncserver xfce4 xfce4-goodies xfonts-base dbus-x11 novnc \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg \ && sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ && apt-get update \ && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 \ --no-install-recommends \ + && ln /usr/share/novnc/vnc.html /usr/share/novnc/index.html \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /app @@ -36,5 +37,7 @@ RUN yarn install EXPOSE 3000 # VNC-server EXPOSE 5901 +# NoVNC +EXPOSE 5900 CMD ./start_container.sh diff --git a/README.md b/README.md index ca753b1..050995a 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ Example request body: "waitOptions": { // selector, xpath or timeout, same as in the goto method "timeout": 5000, //default timeout is 1000ms } - } +} ``` ### **/har** @@ -253,7 +253,7 @@ async function action(page, request) { }; await page.close(); return response; - } +} ``` ### **/screenshot** @@ -270,7 +270,7 @@ Example request body: "quality": 100, "fullPage" : true } - } +} ``` ### **/recaptcha_solver** @@ -324,6 +324,12 @@ You may expect the service to fit 60 open contexts into 1 gigabyte of RAM. Once you don't need the browser tab you need to explicitly close it (e.g. at the end of the parse method). +## VNC and NoVNC + +In case when `HEADLES=false` environment variable is explicitly set, +you may use VNC-server on 5901 port or view NoVNC in browser at localhost:5900. +These provide the ability to check container's process. + ## TODO - [x] skeleton that could handle goto, click, scroll, and actions. diff --git a/start_container.sh b/start_container.sh index 05cfa40..ee4c0a5 100644 --- a/start_container.sh +++ b/start_container.sh @@ -4,6 +4,7 @@ if [ "${HEADLESS}" == "false" ]; then printf "%s\n%s\nn" "${VNC_PASSWORD:=password}" "${VNC_PASSWORD:=password}" | vncpasswd ./start_vnc.sh & + websockify -D 5900 localhost:5901 --web /usr/share/novnc fi # Start scrapy-puppeteer-service